Guest edwinsweep Posted July 7, 2006 Share Posted July 7, 2006 hi everybody.i wonderred if there are more ways than mine to show your database query results.the only way i know is the while loop like this.[CODE]while ($row= mysql_fetch_array($result)) {$row['dbcolname']}[/CODE]i have been trying to get it to work with a foreach loop.but i couln't get it to work.is it because its not possible, or am i just doing something wrong.and why do i have to put the mysql_fetch_array in the while loop, and not just a variable name that contains the fetch thing?if anybody could help me out and clarifie this for me, it would be a great help.thanks in advance. Link to comment Share on other sites More sharing options...
hvle Posted July 7, 2006 Share Posted July 7, 2006 Resultset is a resource type, not an array type, so you can not foreach.Resultset contain an internal pointer. This pointer points to the current row.When you mysql_fetch, result return the current row, then increment this pointer.when result set is query, the pointer pointed at first row or row-0.mysql_data_seek($result, $row); will set the pointer to the row you wanted.and yes, you have to use a function to retrieve data in result.There're many of them. Link to comment Share on other sites More sharing options...
Guest edwinsweep Posted July 7, 2006 Share Posted July 7, 2006 thanks for the answer.a lot clearer now.simple question simple answer:) :) :)thanks and cya later! Link to comment Share on other sites More sharing options...
Recommended Posts