Hello.
I'll first just say that I always research heavily before asking a question - generally I find the answer that way and don't even need to post. But with this one I need a bit more help.
I am pulling numbers(weight) from a single column in the the database between a certain timeframe. I need to get these numbers into a variable array for use elsewhere. I can print the numbers during the while ($array = mysql_fetch_array($result)) { }, but printing them is not what I need, I need them in a named variable.
Following is my code:
............
mysql_select_db("$dbName", $db) or die ("Couldn't select the database.");
$sql = "SELECT weight FROM weight WHERE userID='$userID' AND date>='$date1' AND date<='$date' ORDER BY 'date' ASC" or die(mysql_error());
$result = mysql_query($sql);
while ($array = mysql_fetch_array($result)) {
$weight = $array["weight"];
print "$weight</br>";
}
...........
When I print the array $weight within the loop, I get:
128
126
125
(...etc)
Just as I should. But how do I get those numbers into an array that I can use outside of the {} tags?
Thanks in advance for the help. I get a little topsy turvy when working with arrays...
Jamie