LightningSt Posted May 17, 2008 Share Posted May 17, 2008 I'm trying to make a if statement that basically says If no queries found then... my problem is I'm unsure of how to do the no queries part if($queries = ??????){} Any help would be appreciated. Link to comment https://forums.phpfreaks.com/topic/106096-if-no-queries-found/ Share on other sites More sharing options...
BlueSkyIS Posted May 17, 2008 Share Posted May 17, 2008 need more code. we don't know what $queries is. Link to comment https://forums.phpfreaks.com/topic/106096-if-no-queries-found/#findComment-543781 Share on other sites More sharing options...
LooieENG Posted May 17, 2008 Share Posted May 17, 2008 if ( mysql_num_rows($queries) < 1 ) { // stuff } Is that what you mean? Link to comment https://forums.phpfreaks.com/topic/106096-if-no-queries-found/#findComment-543788 Share on other sites More sharing options...
LightningSt Posted May 17, 2008 Author Share Posted May 17, 2008 that was more of a just how do you do it in general but as for actual code here we go, maybe even whille your at it... the elseif statement isn't working... when i type into the fFirst field and not the fLast and submit it does nothing... but just the else and if work... It will echo the fields are blank or it will do it if there is nothing there if($fFirst == "" AND $fLast == ""){echo "The Required Fields are blank, Please fill them in!";} //Broken Elseif statement, repair in the future (Work) elseif($fLast == ""){$fResult = mysql_query("SELECT * FROM ci WHERE first='$fFirst'");} elseif($fFirst == ""){$fResult = mysql_query("SELECT * FROM ci WHERE last='$fLast'");} // End of Broken else{$fResult = mysql_query("SELECT * FROM ci WHERE first='$fFirst' AND last='$fLast'");} $fResult = mysql_query("SELECT * FROM ci WHERE first='$fFirst' AND last='$fLast'"); Link to comment https://forums.phpfreaks.com/topic/106096-if-no-queries-found/#findComment-543790 Share on other sites More sharing options...
LightningSt Posted May 17, 2008 Author Share Posted May 17, 2008 Yes Thank you that solves my first problem with the if there is no query... now for the elseif statement using the MySql_Num_Rows has allowed me to know that if you fill out only one field, like the elseif statements are trying to say, then it can't find anything in the database Link to comment https://forums.phpfreaks.com/topic/106096-if-no-queries-found/#findComment-543793 Share on other sites More sharing options...
Barand Posted May 17, 2008 Share Posted May 17, 2008 Why are you bothering to test if fields are empty when you always execute the final line regardless of the checks? Link to comment https://forums.phpfreaks.com/topic/106096-if-no-queries-found/#findComment-543807 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.