azocomposto Posted December 4, 2012 Share Posted December 4, 2012 Hello, how can I view (or appear to) a link if the query returns me the number of rows greater than 1? I have write this simple php code, but the message (echo ...) do not appear <?php $resultt = mysql_query (" SELECT * FROM tabella"); $rows=mysql_fetch_array($result); if (mysql_fetch_array($rows) > 0) { echo 'in this area writing a link'; } ?> thanks Link to comment https://forums.phpfreaks.com/topic/271616-display-a-link-only-if-the-query-returns-results/ Share on other sites More sharing options...
Pikachu2000 Posted December 4, 2012 Share Posted December 4, 2012 mysql_num_rows -And- $result != $resultt . . . Link to comment https://forums.phpfreaks.com/topic/271616-display-a-link-only-if-the-query-returns-results/#findComment-1397613 Share on other sites More sharing options...
requinix Posted December 4, 2012 Share Posted December 4, 2012 Since running a query actually makes you get all the results (which mysql_query() does automatically for you) stick a LIMIT 1 on the end so that if there are results you'll only have to discard the one row. Link to comment https://forums.phpfreaks.com/topic/271616-display-a-link-only-if-the-query-returns-results/#findComment-1397617 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.