Webmaster Forum UK
Forum Index -- Databases -- MySql
       ...... Mysql Query
Login
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
LOST



Joined: 27 Mar 2007
Posts: 1

PostPosted: Tue Mar 27, 2007 10:13 pm    Post subject: Mysql Query Reply with quote

I have been looking for a solution to a problem for a couple of weeks i seems to and have got stuck now. Any help or direction would be great

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

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=\"p... src=\"images/vote.png\" onclick=\"up(this)\">;
}
Back to top
View user's profile Send private message
Alex Steel



Joined: 27 Mar 2007
Posts: 7

PostPosted: Tue Mar 27, 2007 10:43 pm    Post subject: Reply with quote

What's the purpose of the double queries? I can't read what's on the dot's, how do you want the results to look like? The solution will probably be a 'join' but I can't answer the question before you've answered mine. Razz
Back to top
View user's profile Send private message
chrishirst



Joined: 29 Mar 2007
Posts: 40
Location: Blackpool

PostPosted: Thu Mar 29, 2007 1:00 pm    Post subject: Reply with quote

You could not join both those queries AND get the results you would be expecting

the second query returns up to 9 rows from ALL rows in ID order (though I don't quite see the point of that )

the first query returns the ID of any member from a given IP (spammer detection)

if they were joined it would return up to 9 rows in ID order from a filtered set on a given IP
_________________
Chris.

So long, and thanks for all the fish.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum