Jump to content

PHP echo problem, only one row :(


amycoll

Recommended Posts

This is an script which recieves a news from database (MySQL).

There are 4 news in database, but echo prints only one of them. (first).

		  
	  mysql_connect("localhost", "root", "pass");
	  mysql_select_db("commander");
	  
	  $query = mysql_query("SELECT * FROM news");
	  $rows = mysql_fetch_array($query);
	  
	  echo "$rows[title]";
                              echo "$rows[description]";

Link to comment
https://forums.phpfreaks.com/topic/197452-php-echo-problem-only-one-row/
Share on other sites

If you only use $row['world'] type use mysql_fetch_assoc if you want to do something like list($field1, $field2) then use mysql_fetch_row mysql_fetch_array returns both whereby you get:

 

Array ( [0] => hello, ['world'] => hello, [1] => bar, ['foo'] => bar )

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.