Hello, I was wondering how I would go about looking up information in a MySQL database inside an if statement, and if it exists, skip the functions inside the if function. Like, if (mysql data found = true) { code } Thanks! Edit: The thing being looked for in the database isnt specific, it would be like, say, a visitor came to your website last night and his/her ip address was logged. Then when he/she comes again today, I would need to check that via the code I am trying to get, and perform some code if its found.
$Q = mysql_query("SELECT * FROM `tablenamehere` WHERE `ip` = '".$_SERVER['REMOTE_ADDR']."' LIMIT 1"); if ($Q){ //blabla }; PHP: something like that should work for u...change colum and table names to fit.
you will want to do this: $sql = "[your sql statement here]"; $rst = mysql_query($sql); if(mysql_num_rows() > 0) { // code if found } else { // code if not found } Code (markup):
ok - made a small mistake corrected as below: $sql = "[your sql statement here]"; $rst = mysql_query($sql); if(mysql_num_rows([COLOR="Red"][B]$rst[/B][/COLOR]) > 0) { // code if found } else { // code if not found } Code (markup):