Jump to content


Name for array element instead of number...

  • Please log in to reply
4 replies to this topic

#1 AncientSage

  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 05 August 2006 - 06:42 PM


I'm getting results from a database, and it's doing as I expect, however, if I do something like this...


...where config_name is the column, and file_size is the row, I cannot access it. Instead, I have to do this:


To access it, then, I have a $row[0]['config_value'] column/values, however, I don't want to be fetching a number and guess around with what I have, so I'd like the name in replacement of 0 to be as well, the name of config_name.

So yes, I want to be able to access a part of that array, by the name of a row in in config_name. Thanks.

Sorry if I didn't explain that well, I'll explain it better, if needed.

#2 redarrow

  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 05 August 2006 - 06:46 PM


your have to assign a varable to the name for it to make human sence ok.

Wish i new all about php DAM i will have to learn

#3 AncientSage

  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 05 August 2006 - 07:11 PM

Meh. So there is no easier way to force it to use names instead of numbers when drawing from a database?

Then I guess I'll have to make sure I do this all very carefully.

#4 wildteen88

  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 05 August 2006 - 07:17 PM

If you are getting results from a database use mysql_fetch_assoc, this returns an associative array, for example it uses the fields names for the array key rather than a number, rather than mysql_fetch_row.

#5 Barand

  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 05 August 2006 - 07:24 PM

I'm getting results from a database....

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users