AncientSage Posted August 5, 2006 Share Posted August 5, 2006 Hello,I'm getting results from a database, and it's doing as I expect, however, if I do something like this...$row['config_name']['file_size']...where config_name is the column, and file_size is the row, I cannot access it. Instead, I have to do this:$row[0]['config_name']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.[i]Sorry if I didn't explain that well, I'll explain it better, if needed.[/i] Quote Link to comment https://forums.phpfreaks.com/topic/16653-name-for-array-element-instead-of-number/ Share on other sites More sharing options...
redarrow Posted August 5, 2006 Share Posted August 5, 2006 $config_name0=$row[0]['config_name'];your have to assign a varable to the name for it to make human sence ok. Quote Link to comment https://forums.phpfreaks.com/topic/16653-name-for-array-element-instead-of-number/#findComment-69884 Share on other sites More sharing options...
AncientSage Posted August 5, 2006 Author Share Posted August 5, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/16653-name-for-array-element-instead-of-number/#findComment-69897 Share on other sites More sharing options...
wildteen88 Posted August 5, 2006 Share Posted August 5, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/16653-name-for-array-element-instead-of-number/#findComment-69900 Share on other sites More sharing options...
Barand Posted August 5, 2006 Share Posted August 5, 2006 [quote]I'm getting results from a database....[/quote]How? Quote Link to comment https://forums.phpfreaks.com/topic/16653-name-for-array-element-instead-of-number/#findComment-69903 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.