|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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! |
|
#2
|
||||
|
||||
|
Code:
if ($island) {
if ($beds) {
$query = " SELECT * FROM villas WHERE island = '$island' AND beds = '$beds' ";
}
else {
$query = " SELECT * FROM villas WHERE island = '$island' ";
}
}
__________________
~ishnid; Have you tried: [ search.cpan.org | perldoc | Java API | mysql.com | google ] Apostrophes are NOT used for possessive pronouns or for noun plurals, including acronyms. |
|
#3
|
||||
|
||||
|
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 |
|
#4
|
||||
|
||||
|
Thanks for the help guys! This forum rules!
|
![]() |
| Viewing: Dev Shed Forums > Other > Beginner Programming > Simple PHP Navigation Question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|