sted999 Posted April 10, 2009 Share Posted April 10, 2009 Hiya all. I am trying to query the database then display the number of results from the query. I have used an example from a book but it does nothing? Can anyone suggest what I am doing wrong? Thanks. $query = "SELECT * FROM Journey WHERE startStreet LIKE '%$startStreet%' AND startTown LIKE '%$startTown%' AND destinationStreet LIKE '%$destinationStreet%' AND destinationArea LIKE '%$destinationArea%' AND destinationTown LIKE '%$destinationTown%' ORDER by date LIMIT 100"; $result = mysql_query($query); $num_results = $result->num_rows; echo "<p>Number of matches found: " , $num_results , "</p>"; Quote Link to comment https://forums.phpfreaks.com/topic/153461-solved-echoing-number-of-results/ Share on other sites More sharing options...
mmarif4u Posted April 10, 2009 Share Posted April 10, 2009 There are many ways to do it, one is count in your query, but here you can use: mysql_num_rows. $num_results = mysql_num_rows($result); Let us know, it worked or not. Quote Link to comment https://forums.phpfreaks.com/topic/153461-solved-echoing-number-of-results/#findComment-806264 Share on other sites More sharing options...
wildteen88 Posted April 10, 2009 Share Posted April 10, 2009 $result = mysql_query($query); Should be $result = mysqli_query($query); Quote Link to comment https://forums.phpfreaks.com/topic/153461-solved-echoing-number-of-results/#findComment-806267 Share on other sites More sharing options...
sted999 Posted April 10, 2009 Author Share Posted April 10, 2009 Thanks for the help. Managed to get it working through mmarif4u approach. Cheers guys Quote Link to comment https://forums.phpfreaks.com/topic/153461-solved-echoing-number-of-results/#findComment-806271 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.