php - updating a field in the database through a function and calling it -
i'm trying function updates field 'status' in database unpaid paid on click of hyperlink/button. here i'm doing not working. please me debug code.
function pay($idno, $secid) { $query = "update payments set status='paid' idnumber = '$idno' , sec_id = '$secid'"; $result = mysqli_query($mysqli,$query); } $sec_id = '2'; $idno= '3'; echo "<td><a href='' onclick='pay($idno, $secid);' >pay now</a></td>"; }
this attempted nothing happening. sql connection correct i've checked already.
without more information on error appears mysql connection undefined. need pass parameter or reference global:
function pay($idno, $secid) { global $mysqli; $query = "update payments set status='paid' idnumber = '$idno' , sec_id = '$secid'"; $result = mysqli_query($mysqli,$query); } $sec_id = '2';
in addition, can't call php function html attempting do. must ajax call php javascript.
Comments
Post a Comment