Page 1 of 1

dynamic variables with php loop from mysql database

Posted: Sun Aug 04, 2002 3:30 pm
by learning_php_mysql
ok, so i a database with id, name, value. i want to take name and set it equal to the value of it. then i want to take value and set that equal to its value. then i wanna set "name" = "value" so my database will automatically create the config file for my websites. i just started using mysql last night and im really stumped. heres what i have.

<?php
$db = mysql_connect("localhost", "database", "password");
mysql_select_db("database", $db);
$result=mysql_query("SELECT * FROM config", $db);
while($myrow = mysql_fetch_array($result))
{
$myrow["name"] = $myrow["value"];
}
?>

Posted: Sun Aug 04, 2002 3:41 pm
by MattF
in your while loop try this instead of what you had:

echo $myrow['name']." = ".$myrow['value'].";\n";

Posted: Sun Aug 04, 2002 5:08 pm
by twigletmac
Naughty cross-poster, please go here:
http://www.devnetwork.net/forums/viewtopic.php?t=2033
to continue this thread.

Mac