Afficher un message
Vieux 14/09/2007, 15h42   #4
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Looping through fields in a row

On Thu, 13 Sep 2007 16:28:15 +0200, stacey <monkeymynd@gmail.com> wrote:

> Hi All,
>
> I am trying to display a mysql record on the screen. I would rather
> not use specific field names in case the fields change, etc. So, I
> just want to create a simple table with the field names down the first
> column and the corresponding values in the second. I've tried several
> different snippets of code that I found, but I can't seem to get it
> working right.
>
> This is what I've been working off of:
>
> $fieldNames=array_keys($myrow);
>
> But this array have every other value as, what seems to be, a row id.
> Looks like this:
>
> Array ( [0] => 0 [1] => sheet_id [2] => 1 [3] => client_id [4]=> 2
> [5] => business_name [6] => 3 [7] => business_address [8] => 4[9] =>
> business_city)


Don't fetch the result with mysql_fetch_array(), use mysql_fetch_assoc()
instead. mysql_fetch_array() will return both a numerical as named array
by default.
--
Rik Wasmus
  Réponse avec citation
 
Page generated in 0,04593 seconds with 9 queries