I'm trying to execute a SQL query through the input of a dropdown box. Here is what I have in my search file so far:
Code: Select all
<?php
if(isset($_POST['submit'])){
if(isset($_GET['go'])){
$RPrice = $_POST['RPrice'];
//connect to the database
$db=mysql_connect ("beep", "boop", "beep") or die ('I cannot connect to the database because: ' . mysql_error());
//-select the database to use
$mydb=mysql_select_db("blup");
//-query the database table
$SQL = "SELECT ID, name, price FROM Foodlist WHERE price="$RPrice"";
//-run the query against the mysql query function
$result=mysql_query($sql);
//-create while loop and loop through result set
while($row=mysql_fetch_array($result)){
$name =$row['name'];
$ID=$row['ID'];
//-display the result of the array
echo "<ul>\n";
echo "<li>" . "<a href=\"search.php?id=$ID\">" .$name . "</a></li>\n";
echo "</ul>";
}
}
else{
echo "<p>You did it wrong.</p>";
}
}
?>
Parse error: syntax error, unexpected T_VARIABLE in /home/eatade5/public_html/dropsearch.php on line 11
If you need any more information, please let me know. Thanks for your help.