ok, see the code below

<?
$rsQry = mysql_query ("select * from tblCustomer");
$arrQry  = mysql_fetch_row($rsQry);
?>

Now if I try to fetch a Customer's Name from the "Customer_Name" column from the "tblCustomer" table with the following code then I dont get anything:

<?
echo $arrQry["Customer_Name"];
?>

Why?


PS: I have tried this way and it works:

<?
echo $arrQry[0];
?>

But I want to use the column name instead of the column number. Any idea?

Thanx

$arrQry  = mysql_fetch_array($rsQry);

What you're wanting to do is use an ASSOCiative array.
Theres 2 methods of doing this.

mysql_fetch_array($rsQry, MYSQL_ASSOC);

or

mysql_fetch_assoc($rsQry);

while ($row = mysql_fetch_array ($result))
{
echo "$row";
echo "$row[1]";
}

the second argument is kinda optional... :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.