Description
Basic while loop. It selects everything from a table called "table1" and then loops through each row. On each iteration, you can do something with the value for a specficied field. In this case, we echo out the values of the id and "anotherfield" fields.
Snippet
$sql = "SELECT * FROM table1";
$result = mysql_query($sql);
while ($data = mysql_fetch_object($result)) {
echo $data->id;
echo $data->anotherfield;
}
$result = mysql_query($sql);
while ($data = mysql_fetch_object($result)) {
echo $data->id;
echo $data->anotherfield;
}

Post new comment