You did fetch all the data by using '*' in your query, but you can't use '*'
as a wildcard when referring to an associative array (which is what $row
is) - you need to step through each key in the array:

while ($row= mysql_fetch_array($result,MYSQL_ASSOC))
{
        $fields = array_keys($row);
        foreach($fields as $key){
                print ("{$".row[$key]."}");
        }
}

Or you could do it longhand -

while ($row= mysql_fetch_array($result,MYSQL_ASSOC))
{
        print ("{$row["Reason"]}");
        print ("{$row["OtherField1]}");
        print ("{$row["OtherField2]}");
}

Longhand might even be more useful if you want to format your results
nicely.

HTH,

-Andy


> -----Original Message-----
> From: Jack [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 29, 2001 8:13 AM
> To: [EMAIL PROTECTED]
> Subject: Could get all data from MYSQL using Mysql_fetch_array!!
>
>
> Dear all
> I was trying to fetch all the data from one of my table
> "leaverequest", but
> i couldn't fetch all the data if i use the * .
> here is my program, this one is only fetch the Reason field, but
> what i want
> is all the data.
>
> <?
> $dblink=mysql_pconnect("microsoft","console","edshk");
> mysql_select_db("nedcorhk",$dblink);
> $query = "select * from leaverequest";
> $result=mysql_query($query,$dblink);
>
> while ($row= mysql_fetch_array($result,MYSQL_ASSOC))
> {
> print ("{$row["Reason"]}");
> }
> ?>
>
> But can i do it like that way to get all the data? (Showing below) :
>
> <?
> $dblink=mysql_pconnect("microsoft","console","edshk");
> mysql_select_db("nedcorhk",$dblink);
> $query = "select * from leaverequest";
> $result=mysql_query($query,$dblink);
>
> while ($row= mysql_fetch_array($result,MYSQL_ASSOC))
> {
> print ("{$row["*"]}");
> }
> ?>
>
>
> Pls help me!!
>
> Thx
> jack
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
>
>
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to