note 19886 added to ref.mysql

From: Date: Thu, 14 Mar 2002 05:00:54 +0000
Subject: note 19886 added to ref.mysql
Groups: php.notes 
Request: Send a blank email to php-notes+get-27774@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 -- http://www.php.net/manual/en/ref.mysql.php http://master.php.net/manage/user-notes.php?action=edit+19886 http://master.php.net/manage/user-notes.php?action=delete+19886 http://master.php.net/manage/user-notes.php?action=reject+19886

« previous php.notes (#27774) next »