i tried to solve a problem using php, mysql and javascript. i should cliuck a button and ythen the script alters some values in the mysqldatabase. it doesn't work. someone said i had to use ajax but i have never used ajax, please give me some help the internet dazzles me.

<?
$select="select *from aanbiedingen where volgnummer=$volgnummer";
$res=mysql_query($select);
$row=mysql_fetch_array($res);

?>

<FORM>
<INPUT type="button" value="bieden" name="button" onClick=
<?

$select="select *from aanbiedingen where volgnummer=$row[volgnummer]";
$selectres=mysql_query($select);
$selectrow=mysql_fetch_array($selectres);
$gebodenaantal=$selectrow[gebodenaantal]+1;
$naam1=$selectrow[naam];
echo$naam1;echo('hier');
$update="update aanbiedingen set gebodenaantal =$gebodenaantal where volgnummer=$row[volgnummer]";
$updateres=mysql_query($update);

$select1="select *from leden where naam=$naam1";
$selectres1=mysql_query($select1);
$selectrow1=mysql_fetch_array($selectres1);
$aantalbiedingen=$selectrow1[aantalbiedingen]-1;
$update="update aanbiedingen set aantalbiedingen =$aantalbiedingen where naam=$naam1";
$updateres=mysql_query($update);
?>

</FORM>

thanks

lex

Member Avatar for rajarajan2017

No need of ajax in this scenario, better you enhance the code in a structured way, remove onClick. and use the method post in form

<form id="frm1" method="post" action="update.php">
<input type="submit" value="commit">
</form>

Do updation process in update.php by getting the value from the current page

in update.php:

$value=$_POST["val"];

connect to database and use update query to update relevant records.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.