Please Help Me

Discussion in 'PHP' started by Sasikumar, Mar 16, 2008.

  1. #1
    Please help to solve my problem. i want the search information to be display such as :

    Restaurant Name :
    Address :
    County :
    City :
    Suburb :

    I posted including with my coding.. pls help me



    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>

    <body>
    <table width="616" border="0" cellpadding="0" cellspacing="0">
    <!--DWLayoutTable-->
    <tr>
    <td width="616" height="359" valign="top"><h2>Search</h2>
    <form name="search" method="post" action="<?=$PHP_SELF?>">
    Seach for: <input type="text" name="find" /> in
    <Select NAME="field">
    <Option VALUE="fname">Name</option>
    <Option VALUE="faddress">Address</option>
    <Option VALUE="fcountry">Country</option>
    <Option VALUE="fcity">City</option>
    <Option VALUE="fsuburb">Suburb</option>
    </Select>
    <input type="hidden" name="searching" value="yes" />
    <input type="submit" name="search" value="Search" />
    </form>&nbsp;</td>
    </tr>
    </table>
    <?
    //This is only displayed if they have submitted the form
    if ($searching =="yes")
    {
    echo "<h2>Results</h2><p>";

    //If they did not enter a search term we give them an error
    if ($find == "")
    {
    echo "<p>You forgot to enter a search term";
    exit;
    }

    // Otherwise we connect to our Database
    mysql_connect("localhost", "webzwork_red", "58281044") or die(mysql_error());
    mysql_select_db("webzwork_red") or die(mysql_error());

    // We preform a bit of filtering
    $find = strtoupper($find);
    $find = strip_tags($find);
    $find = trim ($find);

    //Now we search for our search term, in the field the user specified
    $data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'");

    //And we display the results
    while($result = mysql_fetch_array( $data ))
    {
    echo $result['fname'];
    echo "<br>";
    echo $result['faddress'];
    echo "<br>";
    echo $result['fcountry'];
    echo "<br>";
    echo $result['fcity'];
    echo "<br>";
    echo $result['fsuburb'];
    echo "<br>";
    echo "<br>";
    }

    //This counts the number or results - and if there wasn't any it gives them a little message explaining that
    $anymatches=mysql_num_rows($data);
    if ($anymatches == 0)
    {
    echo "Sorry, but we can not find an entry to match your query<br><br>";
    }

    //And we remind them what they searched for
    echo "<b>Searched For:</b> " .$find;
    }
    ?>
    </body>
    </html>
     
    Sasikumar, Mar 16, 2008 IP
  2. mytshans

    mytshans Peon

    Messages:
    153
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    mytshans, Mar 16, 2008 IP