MySQL Results

Hey,

My mind has just gone entirely blank and can’t for the life of me remember how to accomplish this:

I have this:

$sql = "SELECT title, initial, sname, addr1, addr2, addr3, addr4, postcode, telephone FROM geoff.customer";
$result = mysql_query($sql) or die(mysql_error());

How can I get each of those fields in it’s own variable? So i will end up with $title, $intial, $sname, $addr1 etc

Thanks

Neil


// ... your code here ...
while ($row = mysql_fetch_assoc($result))
{
  extract($row);
  echo $title, ' , ', $initial, ' , etc etc';
}

Although it’s not really recommended to use extract. It’s better to use $row[‘title’], $row[‘initial’], etc directly, without using extract.