Hi, I am an absolute newbie to PHP programming. I am only farmiliar with the scripts. I have a Mysql database from which I am able to query and put the results into an array. I would now like to use these array values, one at a time to query the database. I understand that results from a database are called resources and they have to be converted into variables before they can be used. Please help me to do this.
Query a database using array elements
Started by billmike, Oct 29 2009 12:23 PM
1 reply to this topic
#1
Posted 29 October 2009 - 12:23 PM
|
|
|
#2
Posted 29 October 2009 - 04:08 PM
$query = mysql_query("SELECT id,name FROM users LIMIT 10") or die(mysql_error());
while($row=mysql_fetch_assoc($query)) {
$arg[$row['id']] = $row['name'];
}
foreach($arg as $id => $value) {
msyql_query("INSERT INTO backup SET `id`=$id, `name`='$value'") or die(mysql_error());
}


Sign In
Create Account

Back to top










