voxanBoxer Posted January 16, 2007 Share Posted January 16, 2007 In ASP I would do this:Do Until db.EOF 'some code here - db("name"), db("email")db.MoveNextLoopI am able to loop in PHP but not advance the database position: if ($result){ $num_rows = mysql_num_rows($result); $row = mysql_fetch_array($result); for($x=0;$x<$num_rows;$x++){ // some code here - $row['name'], $row['email'] } } Link to comment https://forums.phpfreaks.com/topic/34465-how-to-loop-through-database-results/ Share on other sites More sharing options...
voxanBoxer Posted January 16, 2007 Author Share Posted January 16, 2007 (The last sentence of every post gets deleted for some reason)Can someone please show me how to loop through a database?I tried foreach but I couldn't get it to output the results how I wanted them. Link to comment https://forums.phpfreaks.com/topic/34465-how-to-loop-through-database-results/#findComment-162293 Share on other sites More sharing options...
Tandem Posted January 16, 2007 Share Posted January 16, 2007 put the mysql_fetch_array() inside the loop. Link to comment https://forums.phpfreaks.com/topic/34465-how-to-loop-through-database-results/#findComment-162301 Share on other sites More sharing options...
voxanBoxer Posted January 16, 2007 Author Share Posted January 16, 2007 That worked, thanks Link to comment https://forums.phpfreaks.com/topic/34465-how-to-loop-through-database-results/#findComment-162305 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.