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

    Join Date
    Aug 2000
    Location
    Tallahassee, Florida, USA
    Posts
    3
    Rep Power
    0
    I have a database that is being queried that is working how I want it to work. Now that I want to have my users be able to click on the restaurant name and go to another page that has the specific restaurant information on there - I cant get that to work. It seems to pull the right ID number but I just can't seem to get the referencing down to where it works. Can anyone help?

    Mike

    Here is the code that works so far:

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

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

    do {
    $id = $row["id"];
    $restaurant = $row["restaurant"];
    $address1 = $row["address1"];
    $address2 = $row["address2"];
    $city = $row["city"];
    $state = $row["state"];
    $zip = $row["zip"];
    $phone = $row["phone"];
    $fax = $row["fax"];
    $website = $row["website"];
    $cuisine = $row["cuisine"];

    echo ("</span></td><td><span class=hometext><a href=searchdetail.php3?id=$id>");
    echo $restaurant;
    echo ("</a></span></td><td><span class=hometext>");
    echo $address1;
    echo ("</span></td><td><span class=hometext>");
    echo $city;
    echo ("</span></td></tr>");

    } while($row = mysql_fetch_array($result));

    And here is the code from the second page where I just get a blank document:

    $result = mysql_query ("SELECT * FROM restaurants
    WHERE id LIKE '$id'
    ");

    $id = $row["id"];
    $restaurant = $row["restaurant"];

    echo ("<tr><td width=150 align=right><span class=hometext><b>ID:</b></span><td><span class=hometext>");
    echo $id;
    echo ("</td></tr><tr><td width=150 align=right><span class=hometext><b>Restaurant:</b></span><td><span class=hometext>");
    echo $restaurant;

  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    2
    Rep Power
    0
    Hmmm not sure if I got the question right, beggin' your pardon in advance if I didn't
    The problem is how to pass variables from one page to another - the easiest answer is to do a hidden field like this:

    --------------1.php------------------
    <?php
    //assume you have your restaurant's name in
    //$rest
    print ("<form method=get action=2.php");
    //all your needed fields and then
    print ("<input type=hidden name=rest value=$rest"> );
    print ("<input type=submit></form>");
    ?>

    and then when you press on submit

    --------------2.php------------------
    //since you know for sure the name of
    //variable from the query string which
    //contains restaurant's name you can
    //use parse_str()

    <?php
    $query=getenv(QUERY_STRING);
    parse_str($query);
    //thats it, now variable $rest contains
    //needed name parsed from the query string.
    print $rest;
    ?>

    Or if you want a link just do a link to 2.php
    with a parameter:
    <a href="2.php?rest=restname">Link</a>
    and then do same parse.

    Sorry again if I misunderstood the question and wrote things everyone knows for ages.

    Kostya Balashov aka GwynBleidd
    gwyn@kaos.dp.ua
    UIN 104918

Similar Threads

  1. Using PHP to display dynamic variables from loops
    By tryin2learnphp in forum PHP Development
    Replies: 1
    Last Post: February 17th, 2004, 12:51 AM
  2. Replies: 7
    Last Post: February 16th, 2004, 02:55 PM
  3. Pass a varaible to another page (parent)
    By sanj in forum HTML Programming
    Replies: 2
    Last Post: February 6th, 2004, 12:59 PM
  4. Cannot get variables to pass
    By VinnyWolf in forum PHP Development
    Replies: 4
    Last Post: February 4th, 2004, 07:38 PM
  5. php code to use variables from the url
    By Nullified in forum PHP Development
    Replies: 2
    Last Post: January 30th, 2004, 02:19 PM

IMN logo majestic logo threadwatch logo seochat tools logo