christo16 Posted February 23, 2007 Share Posted February 23, 2007 Ok this may be an easy one, if my query doesn't find anything how do I make it output some text. Example, so if my query below doesn't find what its looking for $result = mysql_query('SELECT * FROM staffing WHERE date = "'.$variable.'"'); while ($row = mysql_fetch_array($result)) { echo 'Yay I found it!'; } and if it doesn't find anything output some text: echo 'Sorry I could not find it'; Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/39744-if-else-for-a-mysql-query/ Share on other sites More sharing options...
worldworld Posted February 23, 2007 Share Posted February 23, 2007 I think you have to use mysql_nums_rows() to find that query has any row found for you or not. Quote Link to comment https://forums.phpfreaks.com/topic/39744-if-else-for-a-mysql-query/#findComment-191904 Share on other sites More sharing options...
fenway Posted February 23, 2007 Share Posted February 23, 2007 Actually, if all you want to see is if any records match, but don't actually want the records, a COUNT() will suffice. Quote Link to comment https://forums.phpfreaks.com/topic/39744-if-else-for-a-mysql-query/#findComment-192294 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.