Echo-ing Only Available Database Result

Posted by Robert Hanson on Stack Overflow See other posts from Stack Overflow or by Robert Hanson
Published on 2012-11-01T16:58:40Z Indexed on 2012/11/01 17:00 UTC
Read the original article Hit count: 139

Filed under:

I have this Associative Array :

$Fields = array("row0"=>"Yahoo ID", "row1"=>"MSN ID", "row2"=> "Gtalk ID");

on the other side, I have this SQL query :

SELECT YahooID, MSNID, GTalkID From UserTable WHERE Username = '$Username' LIMIT 1;

the result maybe vary, because some users only have Yahoo ID and some have others. for example if I have this result :

$row[0] = NONE //means YahooID = NONE
$row[1] = [email protected]
$row[2] = [email protected]

then how to have this as an output (echo) :

MSN ID = [email protected]

Gtalk ID = [email protected]

since Yahoo ID is not exist, then the result will be MSN and Gtalk only. 'MSN ID' and 'Gtalk ID' is variable from Associative Array, while '[email protected]' and '[email protected]' from SQL result.

thanks!

© Stack Overflow or respective owner

Related posts about php