dynamic variables with php loop from mysql database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
learning_php_mysql
Forum Commoner
Posts: 27
Joined: Sun Aug 04, 2002 12:58 pm
Location: WA

dynamic variables with php loop from mysql database

Post 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"];
}
?>
MattF
Forum Contributor
Posts: 225
Joined: Sun May 19, 2002 9:58 am
Location: Sussex, UK

Post by MattF »

in your while loop try this instead of what you had:

echo $myrow['name']." = ".$myrow['value'].";\n";
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Naughty cross-poster, please go here:
http://www.devnetwork.net/forums/viewtopic.php?t=2033
to continue this thread.

Mac
Locked