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
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.