Jump to content

[SOLVED] A little problem reteiving data from databse and using if function


npsari

Recommended Posts

I have a table called amigos, which contain thousands of FriendIDs

 

I did this code, which will check if a specific friendID is in the latest 15

 

$qcheck = "SELECT * FROM amigos WHERE FriendID=$FriendID ORDER BY Date DESC, Time DESC LIMIT 0, 15;";

$rescheck = @mysql_query($qcheck,$con);

 

if(mysql_num_rows($rescheck)>0){

print"Your ID is already in the latest 15!";

}else{

print "You ID is not in the latest 15";

}

 

but it always gives the result that is in the latest 15

even if it is far earlier

Why, did i do anything wrong in the query guys?

You are selecting the last 15 for that friendId.

 

If you want the last 15 records and then see if friend_id is in those, then

$qcheck = "SELECT latest.* FROM
                    (SELECT * FROM amigos ORDER BY Date DESC LIMIT 15) as latest
                WHERE latest.FriendID=$FriendID";

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.