How do you restart a while mysql_fetch_array loop?
while($row=mysql_fetch_array($result)){
echo $row['id']."<br>"; // will echo all the IDs
}
while($row=mysql_fetch_array($result)){ // won't run at all
echo $row['id']."<br>";
}
How do you restart a while mysql_fetch_array loop?
while($row=mysql_fetch_array($result)){
echo $row['id']."<br>"; // will echo all the IDs
}
while($row=mysql_fetch_array($result)){ // won't run at all
echo $row['id']."<br>";
}
You could do the query again?
while($row=mysql_fetch_array($result)){
echo $row['id']."<br>"; // will echo all the IDs
}
$result = mysql_query($query);
while($row=mysql_fetch_array($result)){ // won't run at all
echo $row['id']."<br>";
}
yeah that’s the simplest way, but it wouldn’t it be more efficient to restart the loop than call the mysql server?
How about this: ? I’ve never tried it …
mysql_data_seek($result, 0);
http://ca.php.net/manual/en/function.mysql-data-seek.php
Red
You could alsways put the results from the query into a non mysql array format
$new_array = array();
while($row=mysql_fetch_array($result)){
$new_array[] = $row['id'];
}
Then you can use that array in any format you like
foreach($new_array as $data) {
//etc
}
Thank you Red, that did the trick!