bluntedbynature Posted May 3, 2005 Share Posted May 3, 2005 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 Quote Link to comment https://forums.phpfreaks.com/topic/2295-multiable-querys/ Share on other sites More sharing options...
bluntedbynature Posted May 5, 2005 Author Share Posted May 5, 2005 bump Quote Link to comment https://forums.phpfreaks.com/topic/2295-multiable-querys/#findComment-7541 Share on other sites More sharing options...
Pilot-Doofy Posted May 29, 2005 Share Posted May 29, 2005 bump 231880[/snapback] 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. Quote Link to comment https://forums.phpfreaks.com/topic/2295-multiable-querys/#findComment-7650 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.