RE: [PHP-DB] create data array

From: Date: Thu, 27 Sep 2001 13:20:02 +0000
Subject: RE: [PHP-DB] create data array
Groups: php.db 
Request: Send a blank email to php-db+get-12775@lists.php.net to get a copy of this message
the following assumes you've opened database. $query = "SELECT TextVal,Val1,Val2,Val3 FROM mytable WHERE some_condition"; $result = mysql_query($query) or die(mysql_error()); $mycmd = "\$data_array = array ("; while( $row = mysql_fetch_array($result) ) { $mycmd .= "array(\"".$row['TextVal']."\",".$row['Val1'].",".$row['Val2'].",".$row['Val 3']."),"; } $mycmd = substr($mycmd,0,-1).");"; print $mycmd; \\ sanity check...display $mycmd eval($mycmd); \\ execute the command. $data_array is created mysql_free_result($result); -----Original Message----- From: Sommai Fongnamthip [mailto:sommai@thaithanakit.co.th] Sent: Thursday, September 27, 2001 2:14 AM To: php-db@lists.php.net Subject: [PHP-DB] create data array Hi, If I need to use data array like this $data_array = array ( array("text",1,2,3), array("text",4,5,6), array("text",7,8,9) ); all array element are contain in my database. How could I write PHP code to make this command on the fly? SF -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#12775) next »