Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

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 July 15th, 2003, 02:33 PM
savantmg's Avatar
savantmg savantmg is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: St. John, US Virgin Islands
Posts: 58 savantmg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 2 m 25 sec
Reputation Power: 6
Simple PHP Navigation Question

Hello,

I'm trying to set up a simple script to help me navigate through a database for a villa company.

Each island has a page containing links to 1-2 bedroom, 3 bedroom and 4 bedroom villas/homes.

There are 12 islands in all. I have a database set up with $islands and $beds as fields, and would like to simply link the page with the bedroom options like the following:

http://www.lime-coconut.com/homes.php?island=St. John&beds=3

... to take the user to the 3 bedroom villas on St. John. It's a simple question (I think) and just can't find the answer how to set up a link and use the & to match multiple queries.

Here is my code thus far (it's all messed up):

if ($island) {
$query = " SELECT * FROM villas WHERE island = '$island' ";
}
$result=mysql_query($query);

$num=mysql_numrows($result);

How can I add the option to further sort using the '&beds=3' in the link?

Thanks a ton to anybody that can help!

Reply With Quote
  #2  
Old July 16th, 2003, 05:23 AM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Sep 2001
Location: Dublin, Eire
Posts: 5,554 ishnid User rank is General 6th Grade (Above 100000 Reputation Level)ishnid User rank is General 6th Grade (Above 100000 Reputation Level)ishnid User rank is General 6th Grade (Above 100000 Reputation Level)ishnid User rank is General 6th Grade (Above 100000 Reputation Level)ishnid User rank is General 6th Grade (Above 100000 Reputation Level)ishnid User rank is General 6th Grade (Above 100000 Reputation Level)ishnid User rank is General 6th Grade (Above 100000 Reputation Level)ishnid User rank is General 6th Grade (Above 100000 Reputation Level)ishnid User rank is General 6th Grade (Above 100000 Reputation Level)ishnid User rank is General 6th Grade (Above 100000 Reputation Level)ishnid User rank is General 6th Grade (Above 100000 Reputation Level)ishnid User rank is General 6th Grade (Above 100000 Reputation Level)ishnid User rank is General 6th Grade (Above 100000 Reputation Level)ishnid User rank is General 6th Grade (Above 100000 Reputation Level)ishnid User rank is General 6th Grade (Above 100000 Reputation Level)ishnid User rank is General 6th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 3 Days 17 h 56 m 2 sec
Reputation Power: 1392
Code:
if ($island) { 
   if ($beds) {
       $query = " SELECT * FROM villas WHERE island = '$island' AND beds = '$beds' "; 
   }
   else {
       $query = " SELECT * FROM villas WHERE island = '$island' "; 
   }
} 

Reply With Quote
  #3  
Old July 16th, 2003, 05:44 AM
SilkySmooth's Avatar
SilkySmooth SilkySmooth is offline
Newbie :P
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2001
Location: In the PHP Engine :-)
Posts: 2,880 SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level)SilkySmooth User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 11 h 32 m 23 sec
Reputation Power: 15
You should also do some checking on the data passed through the URL to make sure no one edits it with something dangerous. Take a look at the thread about PHP Security at the top of the PHP forum.
__________________
---------------------
-- SilkySmooth --
---------------------
Proxy | Little Directory

Reply With Quote
  #4  
Old July 16th, 2003, 08:32 AM
savantmg's Avatar
savantmg savantmg is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: St. John, US Virgin Islands
Posts: 58 savantmg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 2 m 25 sec
Reputation Power: 6
Thanks for the help guys! This forum rules!

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > Simple PHP Navigation Question


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 1 hosted by Hostway