Want to use a database record ID field as array subscript

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
katkat
Forum Newbie
Posts: 23
Joined: Tue Mar 03, 2009 9:50 pm

Want to use a database record ID field as array subscript

Post by katkat »

Hello,
Newbie alert!!

I have a very small database and need to use the automatic id field that is generated in the database as the subscript to an array.

For example:

$ct = $result_row["runnerid"];
$fname["$ct"] = $result_row["firstname"];
$lname["$ct"] = $result_row["lastname"];

The $result_row comes from the database. The runnerid is the ID field in each record. When I display $fname["ct"], the actual word "array" displays. I know the $result_row has the right values but I can't seem to get the $fname and $lname to work as arrays with the $ct as a subscript.

Any advice?
katkat
Forum Newbie
Posts: 23
Joined: Tue Mar 03, 2009 9:50 pm

Re: Want to use a database record ID field as array subscript

Post by katkat »

got it! thanks for your help!
Post Reply