1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Tallahassee, Florida, USA
    Rep Power
    I have a database that I am setting up to be queried which I have working well. The user can search for a restaurant within a city. I have it print the results into a table. Now I want to be able to have a user click on one of the restaurant and get some more specific information about that one restaurant. Any suggestions on how to take care of this easily? Below, I have included my code. Thanks for your help!


    $result = mysql_query ("SELECT * FROM restaurants
    WHERE restaurant LIKE '$restaurant%'
    AND city LIKE '$city%'
    ORDER by restaurant

    if ($row = mysql_fetch_array($result)) {

    do {
    echo ("<tr><td><span class=hometext>");
    echo $row["restaurant"];
    echo ("</span></td><td><span class=hometext>");
    echo $row["address1"];
    echo ("</span></td><td><span class=hometext>");
    echo $row["city"];
    echo ("</span></td></tr>");
    } while($row = mysql_fetch_array($result));

    } else {print "Sorry, no records were found!";}
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Rep Power
    I don't do PHP, so here's an overview of how to do what you want to in generic terms:

    When you build the table that displays the results, add a "Details" link. The idea is to manipulate the href of this link to include some GET parameters indicating which restaurant you're linking to. So, what you do, is make the href something like:
    where you've populated $id with the id of the restaurant.

    Then, in your script (myscript.php) you take the GET parameter and stick it into a SQL query that grabs the specific restaurant, e.g.:
    (assuming you've put the id parameter into $id)
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    SELECT *
    FROM restaurants
    WHERE restaurant = '$id'
    AND city = '$city';
    or something along those lines. With that information you can then build a details page.

    The concept is fairly simple -- you provide a more detailed context to your script to get more detailed information.

    Hope that helps you out.

Similar Threads

  1. Replies: 2
    Last Post: January 28th, 2004, 07:07 AM
  2. Using sessions for search / results pages
    By Quirk in forum PHP Development
    Replies: 10
    Last Post: December 15th, 2003, 08:36 PM
  3. Storing results of MySQL query into multiple variables
    By SashaYee in forum PHP Development
    Replies: 2
    Last Post: December 4th, 2003, 09:06 AM
  4. Highlight only one specific word on results page
    By mattboy in forum HTML Programming
    Replies: 0
    Last Post: November 25th, 2003, 12:54 PM
  5. Limit results on 'left join' query
    By tippiedog in forum MySQL Help
    Replies: 1
    Last Post: November 12th, 2003, 07:58 AM

IMN logo majestic logo threadwatch logo seochat tools logo