Do...while?

I need to know if this is right


<?php do { 
echo "<li><a href=\\"profiles.php?id=". $row_dollcollection['id'].">";
echo "<img src=\\"dolls/". $row_dollcollection['thumb'}."  alt=".$row_dollcollection['dollsName'].">"
echo "</a></li>";
} while ($row_dollcollection = mysql_fetch_assoc($dollcollection)); ?> 

where Im trying to make each doll (record in the table) display as a <li>,
the part Im really struggling on is


<?php } while ($row_dollcollection = mysql_fetch_assoc($dollcollection)); ?> 

as that seems really complicated, when im just trying to stay in that loop while there are records in the table so would something like this work?


<?php 
do {
echo "<li><a href=\\"profiles.php?id=". $row['id']."\\">";
echo "<img src=\\"dolls/". $row['thumb']."\\"  alt=".$row_dollcollection['dollsName'].">";
echo "</a></li>";
} while ($row = mysql_fetch_assoc($dollcollection)); 
?> 

Thanks

It works (but seems to produce an error?
http://localhost/nikelantiquedolls/wordpress/?page_id=4
Is there a way to not have the error

actually it not, heres the source


 <li><a href="profiles.php?id="><img src="dolls/"  alt=></a></li>

You don’t want to use a do while loop in this scenario.

Do While loops are meant to perform an iteration then determine if another iteration should occur. In your situation, you are trying to perform output of a list item using mysql data, but you have yet to retrieve the mysql data. The retrieval happens after your first iteration, so your first list item will always throw a warning/error.

You want a while loop, as it checks the condition first, if it is true/returns data, then it executes the creating of a list item.

<?php 
while ($row = mysql_fetch_assoc($dollcollection)) {
echo "<li><a href=\\"profiles.php?id=". $row['id']."\\">";
echo "<img src=\\"dolls/". $row['thumb']."\\"  alt=".$row_dollcollection['dollsName'].">";
echo "</a></li>";
} 
?>

ohhh.
I was always wondering about the difference there.
Thanks

wjhen I run that code, I get this warning…
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in C:\wamp\www
ikelantiquedolls\wordpress\wp-content\plugins\exec-php\includes\runtime.php(42) : eval()’d code on line 5

The table does have 1 record in it

opps, forgot to set the query