The Little Guy Posted July 31, 2008 Share Posted July 31, 2008 Is there a different way that I can go through results from a database without using a loping method such as the "while loop"? Link to comment https://forums.phpfreaks.com/topic/117571-returned-results-without-loop/ Share on other sites More sharing options...
phpSensei Posted July 31, 2008 Share Posted July 31, 2008 I can't think of any other way... edit: nvm, i dot think that would work. Link to comment https://forums.phpfreaks.com/topic/117571-returned-results-without-loop/#findComment-604727 Share on other sites More sharing options...
ikmyer Posted July 31, 2008 Share Posted July 31, 2008 just wondering... why are you looking for a different way? Link to comment https://forums.phpfreaks.com/topic/117571-returned-results-without-loop/#findComment-604734 Share on other sites More sharing options...
The Little Guy Posted July 31, 2008 Author Share Posted July 31, 2008 this seems to work: $sql = mysql_query("SELECT count(*) as countFROM users"); mysql_result($sql,0); mysql_result($sql,1); mysql_result($sql,2); //etc. Link to comment https://forums.phpfreaks.com/topic/117571-returned-results-without-loop/#findComment-604735 Share on other sites More sharing options...
phpSensei Posted July 31, 2008 Share Posted July 31, 2008 why dont you just do $row = mysql_fetch_array($sql); doesnt seem to have any difference from what you are doing there. mysql_fetch_row() mysql_fetch_array() mysql_fetch_assoc() mysql_fetch_object() Link to comment https://forums.phpfreaks.com/topic/117571-returned-results-without-loop/#findComment-604736 Share on other sites More sharing options...
discomatt Posted July 31, 2008 Share Posted July 31, 2008 Is there a different way that I can go through results from a database without using a loping method such as the "while loop"? If you have a constant amount of rows returned, mysql_result( $resource, $rowNum, $colNum ) will return the given cell. This is kinda useless for dynamic data though. Link to comment https://forums.phpfreaks.com/topic/117571-returned-results-without-loop/#findComment-604740 Share on other sites More sharing options...
The Little Guy Posted July 31, 2008 Author Share Posted July 31, 2008 Here is my query: (SELECT COUNT(id) AS count FROM users) UNION (SELECT COUNT(id) as count FROM users GROUP BY gender) UNION (SELECT COUNT(id) as count FROM images) UNION (SELECT COUNT(id) as count FROM videos) UNION (SELECT COUNT(id) as count FROM events) UNION (SELECT COUNT(id) as count FROM leagues) Link to comment https://forums.phpfreaks.com/topic/117571-returned-results-without-loop/#findComment-604748 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.