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

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -