using while and foreach
Posted: Sat Jul 03, 2004 7:12 pm
I need to fetch results from a database, put them into an array, and then use a foreach loop to update a certian table. So far, this is what I have:
Of course, all this does is give me all the user ids with a line break between them, as intended:
What I want to do, however, is put each of those values into an array , then use foreach to insert them into a database. How would I go about doing this? Thanks.
Code: Select all
<?php
include "mysql_connect.php";
$query = "select user_id from users";
$result = mysql_query ($query);
while ($row = mysql_fetch_array ($result, MYSQL_NUM)) {
echo "$row[0]<br>";
}
?>Code: Select all
1
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18