Re: combination of fetch_field and fetch_row

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It appears you didn't get an answer on list. You can try using
mysql_fetch_array() instead of mysql_fetch_row(). Then you'll get an
associative array, with the field names as the keys. So you can do
something like this:

$result0 = mysql_query("SELECT
uitbater,straatnaam,postcode,gemeente,provincie,telefoon,fax,email
FROM info_general") or die (mysql_error());

$get_info0 = mysql_fetch_array($result0);
foreach ($get_info0 as $field=>$value)
{
    print "\t<tr><td>$field</td><td>$value</td></tr>\n";
}



--- gert vonck <gert_vonck@hotmail.com> wrote:
> hey everyone,
> 
> i want to get this result :
> 
> ----------------------------------------------
> | Boss (--> field name) | Mr. Blabla     |
> | Street                | Oxford str.    |
>     ...                       ...
> 
> 
> I did this with :
> 
> $result0 = mysql_query("SELECT 
> uitbater,straatnaam,postcode,gemeente,provincie,telefoon,fax,email
> FROM 
> info_general") or die (mysql_error());
> 
> $get_info0 = mysql_fetch_row($result0);
> 
> 	$i = 0;
> 	while ($i < mysql_num_fields($result0))
> 	{
> 
> 		$meta = mysql_fetch_field($result0);
> 
> 		foreach ($get_info0 as $field0)
> 		{
> 		print "\t<tr><td>$meta->name</td><td>$field0</td></tr>\n";
> 		}
> 		$i++;
> 
> 	}
> 
> He doesn't give an error, but he only prints 8 times the 2nd column
> and 
> nothing in the first (field name column)
> 
> Does anyone know how to solve this?
> 
> Greetz,
> 
> Gert Vonck
> 
> 
> 
> 
> _________________________________________________________________
> Chat with your online buddies with MSN Messenger
> http://messenger.msn.be
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



=====
Mark Weinstock
mark_weinstock@yahoo.com
***************************************
You can't demand something as a "right" unless you are willing to fight to death to defend everyone else's right to the same thing.
***************************************

__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux