Jump to content

multiable querys


Recommended Posts

  • 4 weeks later...
  Quote
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.

Link to comment
https://forums.phpfreaks.com/topic/2295-multiable-querys/#findComment-7650
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.