Aureole Posted July 24, 2007 Share Posted July 24, 2007 I want to query the MYSQL database for all news articles then show something like: We have a total of x news articles. How would I go about doing this? Link to comment https://forums.phpfreaks.com/topic/61501-solved-check-how-many-articles-and-display/ Share on other sites More sharing options...
Aureole Posted July 24, 2007 Author Share Posted July 24, 2007 I know I need to do this... $query = "SELECT id FROM news"; $result = @mysql_query($query) or die(mysql_error()); And I realize I need to do something with "mysql_num_rows" but I don't know how. Link to comment https://forums.phpfreaks.com/topic/61501-solved-check-how-many-articles-and-display/#findComment-306128 Share on other sites More sharing options...
vbnullchar Posted July 24, 2007 Share Posted July 24, 2007 <?php $link = mysql_connect("localhost", "mysql_user", "mysql_password"); mysql_select_db("database", $link); $result = mysql_query("SELECT * FROM table1", $link); $num_rows = mysql_num_rows($result); echo "We have a total of $num_rows ews articles.\n"; ?> http://www.php.net/mysql_num_rows Link to comment https://forums.phpfreaks.com/topic/61501-solved-check-how-many-articles-and-display/#findComment-306130 Share on other sites More sharing options...
Aureole Posted July 24, 2007 Author Share Posted July 24, 2007 Thankyou very, very much. Link to comment https://forums.phpfreaks.com/topic/61501-solved-check-how-many-articles-and-display/#findComment-306136 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.