I would love if someone could help me this one, it has been driving me mad for the last week.
I am trying to create a dynamic menu system using Ajax.
This is the code that I am having problems with.
The filename is called getinfo.php
When I call the file via Ajax, then it will show,"Start If Loop" and "End If Loop" only.
If I add in (outside of the Loops)
then it will echo out the correct variable
If I add in (outside of the Loops)
then it will echo out the correct SQL statement.
If I call the file separately with getinfo.php?r=book, then it will output all the information correctly on that page.
If I change the Code as follows
Then this works correctly.
The issue is with the variable r but I can't figure out exactly what.
I am trying to create a dynamic menu system using Ajax.
This is the code that I am having problems with.
The filename is called getinfo.php
Code:
<?php
$r=$_GET["r"];
$db = mysql_connect("servername", "username", "password");
mysql_select_db("dbname",$db);
$sql="SELECT * FROM tablename Where Grouping='$r'";
$result = mysql_query($sql,$db);
echo "Start If Loop";
if ($row = mysql_fetch_array($result)) {
echo "Start Do Loop";
do {
echo "Inside Do Loop";
$product=$row["Product"];
echo $product."<br>";
} while($row = mysql_fetch_array($result));
echo "End Do Loop";
}
echo "End If Loop";
?>
When I call the file via Ajax, then it will show,"Start If Loop" and "End If Loop" only.
If I add in (outside of the Loops)
Code:
echo $r;
If I add in (outside of the Loops)
Code:
echo $sql;
If I call the file separately with getinfo.php?r=book, then it will output all the information correctly on that page.
If I change the Code as follows
Code:
$sql="SELECT * FROM tablename Where Grouping='book'";
The issue is with the variable r but I can't figure out exactly what.