MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 21st, 2000, 11:18 AM
itchythecat itchythecat is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: Tallahassee, Florida, USA
Posts: 3 itchythecat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!";}

Reply With Quote
  #2  
Old August 21st, 2000, 11:31 AM
christucker2 christucker2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 81 christucker2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > multiple results, now want one specific one


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT