PHP Gurus,
        I'm trying to put the results of a query into an array.
        My code looks like this:
<?php
$query = "SELECT datecolumn FROM table WHERE MONTH(datecolumn) = " .
$currentMonth;
$result = mysql_query($query);
$numRows = mysql_num_rows($result);
for($i = 0; $i<$numRows; $i++)
{
        $workshops[$i] = mysql_fetch_row($result);
        echo $workshops[$i] . "<br />";
}
echo "The results of the array are - " . $workshops[0] . " and " .
$workshops[1];
?>
        When I run this, the output to the screen says:
        ---
        Array
        Array
        The results of the array are - Array and Array
        ---
        If I change just this line (take the square brackets off the
$workshops array declaration):
        $workshops = mysql_fetch_row($result);

        Then my results are:
        ---
        2003-11-17

        The results of the Array are 2003-11-24 and
        ---
        I understand that by not using square brackets to declare the
variable explicitly as an array, then it just stores the last value,
which is why the dates aren't echoing to the screen where they are
supposed to. That part makes sense. What I don't understand is why when
I try to put the results into a particular location in the array, it
gets stored as the word "Array". But if I just declare it as a regular
variable, then I get the date that I want.
        I've been writing this out a million different ways to try and
figure out what's going on, I've searched Google, and I've read the
descriptions for the mysql_* commands on php.net. But everything I read
indicates it should work. In fact I got the for() loop from a tutorial
web site, so I'm pretty sure it's supposed to work. I can't see what's
wrong. Am I not declaring the array correctly? Is there some simple
error that I'm over looking? What's going on?

-- 
Cheers!
Dave G
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to