I have a list of records which loop from mysql table, for each record i had assigned an onclick function in order to pass the data for mysql query use to avoid page refresh whenever it was call,
<a href='javascript:void(0)' onclick='PlayMV(\"".$rows["v_type"]."\",\"".$rows["v_id"]."\");'>Play</a>
below is passing values to jquery function:
<script type="text/javascript">
function PlayMV(data1, data2){
$.post("mtv.php", { var1: "data1", var2: "data2" },
function(data){
$('#result').html(data);
});
}
</script>
here comes the problem, the "$('#result').html(data);" was always returned me a whole page in source code instead of held only the values, what I want is only able to post 'data1' and 'data2' and assigned into a php variable and mysql query like below:
$var1 = data1;
$var2 = data2;
$q = mysql_query("SELECT * FROM table WHERE mvtype='".$var1."' AND mvid='".$var2."'");
how to use JSON to pass those data into mysql query to retrieve the final result, can anyone help?
Thanks very much.