I have the following sql for a query:
$sql = "SELECT * FROM `table` WHERE `primary_key` = '1' LIMIT 1";
$query = mysql_query($sql);
$row = mysql_fetch_row($query);
echo $row[0]; // will echo first field (primary_key)
echo $row[1]; // will echo the second field (name)
Is there a way to be able to do the above and echo it out like this:
echo $row[primary_key]; // will echo "primary_key" field
echo $row[name]; // will echo the "name" field
without having to put it into a mysql_fetch_array and while loop like this:
while($row = mysql_fetch_array($query)) {
echo $row[primary_key]; // will echo "primary_key" field
echo $row[name]; // will echo the "name" field
}
Thanks.