Hi everyone
I am new to php, so im having trouble coding what i want to do. here is my code for my basic search engine. The user enters via a form the type of cuisine and the suburb.
<?
$username="kimbedso";
$password="";
$database="kimbedso_mydb";
$cusine=$_POST['cusine'];
$suburb=$_POST['suburb'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM better WHERE cuisine='$cusine' and suburb='$suburb' ";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Database Output</center></b><br><br>";
$i=0;
while ($i < $num) {
$name=mysql_result($result,$i,"name");
$sub=mysql_result($result,$i,"suburb");
$cu=mysql_result($result,$i,"cuisine");
$des=mysql_result($result,$i,"description");
?>
<table width="564" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="392" height="25" valign="top" bgcolor="#99CCFF"><font face="Verdana, Arial, Helvetica, sans-serif"><b><? echo $name ?></b></font></td>
<td width="172" valign="top" bgcolor="#99CCFF">
<div align="right"><font face="Verdana, Arial, Helvetica, sans-serif"><? echo $sub ?></font></div>
</td>
</tr>
<tr bgcolor="#CCFFFF">
<td colspan="2" height="173" valign="top"><font face="Verdana, Arial, Helvetica, sans-serif"><? echo $des ?></font></td>
</tr>
</table>
<?
$i++;
}
?>
I think this script is fine, however i wish to add a checkbox, that when ticked will tell the script to search for the neighbouring suburbs as well. To do this I have created another column in my table called "suburb id" I have given each suburb a unique number, and to find the neighbouring suburbs you just add +1 +2 +3 -1 -2 -3 to the suburb id.
So ill describe what i want the script to do
If: checkbox isnt ticked then basically execute the code written above
elseif: get the "suburb" value posted from the users form. Get this suburbs "suburb id" and display all the results for this suburb. add 1 to this id, and then display the results for this neighbouring suburb. then -1 from the id and display values. then +2, -2 up to 3.
Can anyone give me pointers on how to write the code for this?




Bookmarks