RE: [PHP] Generating populated variables from component/content p airs in a database

From: Date: Fri, 01 Feb 2002 20:17:52 +0000
Subject: RE: [PHP] Generating populated variables from component/content p airs in a database
Groups: php.general 
Request: Send a blank email to php-general+get-83178@lists.php.net to get a copy of this message
$sql = "SELECT * FROM $table_name WHERE sec = '$sec' AND WHERE subsec = '$subsec' AND WHERE name = '$name' ORDER BY component "; $result = mysql_query($sql) or die("Error: ".mysql_error()."$sql<BR>"); while ( link($component,$content) = mysql_fetch_array($result) ) { ...do stuff... } The filed values will be in the $component and $content. -----Original Message----- From: James Hallam [mailto:jhallam@dwl.net] Sent: Friday, February 01, 2002 3:07 PM To: php-general@lists.php.net Subject: [PHP] Generating populated variables from component/content pairs in a database I've got a fairly basic website content management system I'm working on, and I've got the data split up in MySQL by the following: a few columns for identifiers like language, section and unique keyname, a column for a component name and a column for the relevant content for that component. As follows: ==================================== | component | content | ------------------------------------ | foo | 123456 | ------------------------------------ | bar | 654321 | ------------------------------------ Assuming I've got the right sql statement here (it just looks for the rows that match the section and subsection provided earlier in the script): $sql = "SELECT FROM $table_name WHERE sec = '$sec' AND WHERE subsec = '$subsec' AND WHERE name = '$name' ORDER BY component "; What can I do to end up with a variable for each component/content pair, with the variable named with the value of the component, and assigned the value of the content?: $foo = 123456; $bar = 654321; Is there a simple way to do this? Thanks, James Hallam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#83178) next »