lazukars Posted March 26, 2007 Share Posted March 26, 2007 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 More sharing options...
fenway Posted April 4, 2007 Share Posted April 4, 2007 Well, you can just issue a UNION statement.... Link to comment https://forums.phpfreaks.com/topic/44408-multiple-mysql-queries/#findComment-221150 Share on other sites More sharing options...
gluck Posted April 5, 2007 Share Posted April 5, 2007 You could do a self join or do it opening two result sets. Link to comment https://forums.phpfreaks.com/topic/44408-multiple-mysql-queries/#findComment-222607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.