Hello people, I’m currently working on a website, building a booking system.
So…somehow my AJAX is not working and got me question mark =(
Below is the code.
In homepage.php:
<script type=‘text/javascript’>
function change(ro,cc)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
xmlhttp.open(“GET”,“adminupdate.php?q=”+ro+“&w=”+cc, true);
xmlhttp.send(null);
</script>
.
.
.
.
<tr>
<td>Table1</td>
<?php
$slotresult = mysql_query(“select * from checkslot WHERE row=‘1’ AND checkcol=‘1’”); //select all field from logintable and put into result
if(!$slotresult)
{
die("Database connection fail: " . mysql_error());
}
$row2 = mysql_fetch_array($slotresult);
if ($row2[status]==0)
{
?>
<td id=“table11000” onclick=“change(1,1)” style=“background-color:greenyellow”>
<?php
}
if ($row2[status]==1)
{
?>
<td id=“table11000” onclick=“change(1,1)” style=“background-color:red”>
<?php
}
if ($row2[status]==2)
{
?>
<td id=“table11000” onclick=“change(1,1)” style=“background-color:blue”>
<?php
}
?>
.
.
.
In adminupdate.php:
<?php
$connection = mysql_connect(“localhost”,“root”,“123456”) or die(mysql_error());
mysql_select_db(‘bookingdb’,$connection);
$row=$_GET[“q”];
$col=$_GET[“w”];
$slotresult = mysql_query(“UPDATE checkslot SET status=‘1’ WHERE checkcol LIKE ('”.$row.“‘) AND row LIKE (’”.$col."') ");
if(!$slotresult)
{
die("Database connection fail: " . mysql_error());
}
mysql_query($slotresult) or die(mysql_error());
?>
yeah, not sure where the error is, hope you guys can try your best to understand my program thanks for reading.
–>There is no output when onclick and database not updated.
Edit/Delete Message