note 19886 deleted from ref.mysql by jimw

From: Date: Sun, 21 Apr 2002 21:03:01 +0000
Subject: note 19886 deleted from ref.mysql by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-29660@lists.php.net to get a copy of this message
here is an easy way to get records, cause the variable's name = fieldname: $query=mysql_db_query("database","SELECT id, product, price FROM myshop",$resourceid); while($record=mysql_fetch_array($query,MYSQL_ASSOC)){ while(list($key,$val)=each($record)){$$key=$val;} echo "$id: $product available for $price US$<br>"; } explanation: if databases fieldname is 'foo' u can include it into u'r page by using '$foo' - thats simple, isnt it? if u have a strange fieldname use an alias (AS) in the query, f.E.: 'SELECT DATE_FORMAT(FROM_UNIXTIME(start),'%d.%m.%Y') FROM events' wont work, better use this: 'SELECT DATE_FORMAT(FROM_UNIXTIME(start),'%d.%m.%Y') AS date FROM events' greets, chris

« previous php.notes (#29660) next »