Re: Mysql and mysql_fetch_array

From: Date: Mon, 08 Oct 2001 19:35:00 +0000
Subject: Re: Mysql and mysql_fetch_array
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-9772@lists.php.net to get a copy of this message
On Tue, 09 Oct 2001 20:27:07 +0200, Darko wrote: >Hello. >This script gives me every data twice in print if I have database >with >names on database output look like this: > >John John Doe Doe Phone Phone 1234 1234 > >Why? check out the second argument to mysql_fetch_array(): http://www.php.net/manual/en/function.mysql-fetch-array.php ><?php > $link = mysql_connect("mysql_host", "mysql_login", >"mysql_password") > > or die ("Could not connect"); > print ("Connected successfully"); > mysql_select_db ("my_database") > or die ("Could not select database"); > > $query = "SELECT * FROM my_table"; > $result = mysql_query ($query) > or die ("Query failed"); > > // printing HTML result > > print "<table>\n"; > while($line = mysql_fetch_array($result)){ > print "\t<tr>\n"; > while(list($col_name, $col_value) = each($line)){ > print "\t\t<td>$col_value</td>\n"; > } > print "\t</tr>\n"; > } > print "</table>\n"; > > mysql_close($link); >?> > > > > -- Mark, maggelet@mminternet.com on 10/08/2001

« previous php.windows (#9772) next »