Jump to content


Photo

multiable querys


  • Please log in to reply
2 replies to this topic

#1 bluntedbynature

bluntedbynature
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 03 May 2005 - 05:28 PM

ok i need to sort by 2 different things, its a cellular phone site, so i want it to sort by service and make of phone. right now i got it so it sorts the service. phones.php?service=cingular now i want it so it looks like this phone.php?service=cingular&make=Sony Ericson

#2 bluntedbynature

bluntedbynature
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 05 May 2005 - 12:11 AM

bump

#3 Pilot-Doofy

Pilot-Doofy
  • Members
  • PipPip
  • Member
  • 19 posts
  • LocationMustywindows.com!

Posted 29 May 2005 - 06:15 PM

bump

View Post

You didn't need to bump this thread in the first place, someone would eventually get around to it. Considering you only waited a day I was reluctant to help you but since I'm a kind spirited person, I decided to continue with the help.

Have you not read enough on SQL to see that it has an AND operator?

Try this:
$service = addslashes($_GET['service']);
$type = addslashes($_GET['make']);
# I know this isn't completely secure but it's a good start. You can work 
# the rest out.

$get_info = mysql_query("SELECT * FROM cellphones WHERE service = '" . $service . "' AND make = '" . $type . "'") or die ("Error, could not run query. MySQL: " . mysql_error());
# After getting everything working or if you don't run into any problems
# I would remove the or die statement. It is mainly used for only debuggin
# and the user doesn't need to see the structure of your database to know
# what exactly went wrong.

if (mysql_num_rows($get_info) == 0) {
echo 'No results found.';
} else { # Results were found

echo 'Results:<br /><br />
do { # Execute code

echo 'Service: ' . $info['service'] . '<br />
        Make: ' . $info['make'] . '<br />';

} while ($info = mysql_fetch_array($get_info));

} // End else for if (mysql_num_rows($get_info) == 0)


You can always retrieve the rest of the information from your database. I'm not sure if I got the table or fields right but I was just guessing. Fix them if needed.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users