php - Returning a value depending on number of rows returned from SQL query -
i'm new php , sql , i'm trying write function return true if sql query returns @ least 1 result.
what have far
function isnew($cannum) { connecttodatabase(); select count(*) cnt 'cans' c c.date >= date_sub(now(), interval 1 day) , c.canid = '$cannum'; disconnectdatabase(); //return true if above returns row disconnectdatabase(); }
my question how return since count not php variable can < comparison with.
function isnew($cannum) { if (count(mysql_fetch_assoc(mysql_query(" select count(*) cnt 'cans' c c.date >= date_sub(now(), interval 1 day) , c.canid = '$cannum'; ")))>0) { return true; } else { return false; } }
Comments
Post a Comment