Jump to content

Multiple Mysql Queries


lazukars

Recommended Posts

Hi,

 

I have been searching for a solution to the below problem for a couple of weeks now and have reached a brick wall. Any help or direction would be greatly appreciated.

 

Basically, I would like to perform one mysql query, then perform another mysql query, and finally print out the results of both of the two queries via one php print statement. Please see the code below.

 

<?php
$ip_address=$_SERVER['REMOTE_ADDR']; 
$embarrassing_moments_final = $_POST['embarrassing_moments'];
mysql_connect("", "", "") or die(mysql_error());
mysql_select_db("") or die(mysql_error());
$results0 = mysql_query("SELECT id FROM embarrassing WHERE ip_address = '$ip_address'") or die(mysql_error());
$results = mysql_query("SELECT description, votes, id FROM embarrassing ORDER BY id DESC LIMIT 9") or die(mysql_error());
while($row = mysql_fetch_array($results)){
//I would like to have the mysql_fetch_array($results0) values also printed in the line below as variables.//
print "<div id=\"".$row['id']."\"class=\"printed_list\">\n<img src=\"images/vote.png\" onclick=\"up(this)\">\n<span class=\"votes_text\">\nvotes:\n<span class=\"votes\">\n".$row['votes']."\n</span>\n</span>\n<br/>".$row['description']."\n</div>\n";
} 
?>

Link to comment
https://forums.phpfreaks.com/topic/44408-multiple-mysql-queries/
Share on other sites

  • 2 weeks later...

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.