Re: print a element of a column
| From: | John Nichel | Date: | Sun, 29 Aug 2004 15:20:09 +0000 |
| Subject: | Re: print a element of a column | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-195082@lists.php.net to get a copy of this message | ||
devil_online wrote:
Hi, I want to print each element of a column of a mysql database. For exemple to print the first element could we do like this:You need to loop thru the result set if it's going to return more than one row.... while ( $column = mysql_fetch_array ( $result ) { print $column[0]; } In your query above, there won't be a $column[1] [2], etc., since you're only selecting 'username'. 'username' will be the first and only element. -- By-Tor.com It's all about the Rush http://www.by-tor.comCode:$result = mysql_query( "SELECT username FROM users" ); $column = mysql_fetch_array($result); print $column[1]; print $column[3];Thanks