trq Posted October 9, 2008 Share Posted October 9, 2008 $mquery is a result resource, not an array. You need to pull a record (as an array) from this resource. eg; <?php ini_set('display_errors', 1); error_reporting(E_ALL); $query ="SELECT * FROM `news` ORDER BY `date` DESC LIMIT 5"; if ($mquery = mysql_query($query)) { if (mysql_num_rows($mquery)) { ?> <table width="10" border="1" cellspacing="0" cellpadding="0"> <tr> <th scope="row">Author Name</th> </tr> <tr> <th scope="row">Date</th> </tr> <tr> <th scope="row">Topic</th> </tr> <tr> <th scope="row">Articale</th> </tr> </table> <?php while ($data = mysql_fetch_assoc($mquery)) { //this will loop through your row data returned from the db echo "<tr bgcolor=#EEEEEE>\n"; echo "<td>{$data['authorname']}</td>\n"; echo "<td>{$data['date]'}</td>\n"; echo "<td>{$data['newstitle']}</td>\n"; echo "<td>{$data['news']}</td>\n"; echo "</tr>\n"; } } else { echo "No results found"; } } else { echo mysql_error(); } ?> </table> I also added better tests of your results. Link to comment https://forums.phpfreaks.com/topic/127618-solved-display-information-from-the-mysql-database/page/2/#findComment-660417 Share on other sites More sharing options...
topflight Posted October 9, 2008 Author Share Posted October 9, 2008 Now I am receiving this Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\viewnews.php on line 48 and line 48 is while($data = mysql_fetch_assoc($mquery){ //this was changed Link to comment https://forums.phpfreaks.com/topic/127618-solved-display-information-from-the-mysql-database/page/2/#findComment-660423 Share on other sites More sharing options...
topflight Posted October 9, 2008 Author Share Posted October 9, 2008 thorpe for your code I am now receiving this Parse error: syntax error, unexpected '}', expecting ']' in C:\xampp\htdocs\viewnews.php on line 50 Link to comment https://forums.phpfreaks.com/topic/127618-solved-display-information-from-the-mysql-database/page/2/#findComment-660426 Share on other sites More sharing options...
CroNiX Posted October 9, 2008 Share Posted October 9, 2008 while($data = mysql_fetch_assoc($mquery){ should be while($data = mysql_fetch_assoc($mquery)){ Link to comment https://forums.phpfreaks.com/topic/127618-solved-display-information-from-the-mysql-database/page/2/#findComment-660434 Share on other sites More sharing options...
topflight Posted October 9, 2008 Author Share Posted October 9, 2008 Thanks all it works I hope I did not bother you guys. PHP freaks has been a big help when it comes to learning php well I am going to start reading this book and start learning php the right way thanks all. Link to comment https://forums.phpfreaks.com/topic/127618-solved-display-information-from-the-mysql-database/page/2/#findComment-660446 Share on other sites More sharing options...
CroNiX Posted October 9, 2008 Share Posted October 9, 2008 No problem and good luck. Its not that hard once you get some concepts down. Link to comment https://forums.phpfreaks.com/topic/127618-solved-display-information-from-the-mysql-database/page/2/#findComment-660451 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.