SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2004
    0 Post(s)
    0 Thread(s)

    unsure, quick problem

    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.


    @mysql_select_db($database) or die( "Unable to select database");
    $query="SELECT * FROM better WHERE cuisine='$cusine' and suburb='$suburb' ";



    echo "<b><center>Database Output</center></b><br><br>";

    while ($i < $num) {



    <table width="564" border="0" cellpadding="0" cellspacing="0">
    <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>
    <tr bgcolor="#CCFFFF">
    <td colspan="2" height="173" valign="top"><font face="Verdana, Arial, Helvetica, sans-serif"><? echo $des ?></font></td>



    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?

  2. #2
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    West Midlands, United Kingdom
    0 Post(s)
    0 Thread(s)
    If the check box is called suburb! imaginative I know! lol!


    PHP Code:
    if(isset($_POST['suburb'])) {
    // do your stuff for the suburbs
    } else {
    // do your code above


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts