MichaelHooker
Programmer
I've read a lot of guidance about using PHP and MySQL and so far I'm successfully retrieving all sorts of complicated joined stuff from my tables. But the established way of retrieving data which is in all the guidance seems way over the top when all you want to do is retrieve a single column from a single unique record - like using an ini file, or a name/value list in Delphi. Currently, to fetch a person's e-mail address when I know their name, I do this:
It works, but wouldn't it be neater if you didn't have to fetch an array of one item and then extract the value from the zero'th element?
Go on, tell me I've missed something simple, it wouldn't be the first time
Michael Hooker
Code:
<?php>
$query = "SELECT Email FROM Addresslist WHERE Name = '".$Searchstring."'";
$result = mysql_query ($query);
$row = mysql_fetch_array($result);
$address = $row[0];
//$address is later used as a parameter to "mail()" as $row is used for another query before we get to that point
<?>
It works, but wouldn't it be neater if you didn't have to fetch an array of one item and then extract the value from the zero'th element?
Go on, tell me I've missed something simple, it wouldn't be the first time
Michael Hooker