|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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!
Mike $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
|
|||
|
|||
|
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: myscript.php?restaurant_id=$id 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'; [/code] 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. |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > multiple results, now want one specific one |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|