Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
OK, perhaps someone can help me out and let me know what I've done wrong here.
I run a SQL query, and then want to add the results to an array which is returned as the result of this function.
Here is my code:Code: Select all
while ($row = mysql_fetch_array($result)) {
$returnData["weight"][] = $row["id"];
$returnData["weight"][$row["id"]]["display"] = $row["imperial"] ." / ". $row["metric"];
}$returnData["weight"]["1"]["3 lbs / 1 kg"] ... etc.
So, in my debugging, I noticed that if I do:
echo $returnData["weight"]["1"]["display"];
I get the proper result displayed (3 lbs / 1 kg). But, if I do anything but the first value, I get some weird number (like "9" or "1") that doesn't correspond to $row["imperial"] or $row["metric"] or anything else I can see.
I'm thinking the way I add to the $returnData array might not be right, but I don't know what would be off -- and if something is off, why is the first one right!?
Hope someone can help.
Thanks!
Jcart | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]