JustinK101 Posted October 30, 2010 Share Posted October 30, 2010 Assuming I have a result object: $result = mysqli_query($sql_string); How can I get specific rows, i.e. multiple rows are returned 8 total, but I was rows 2-6. Thanks. Link to comment https://forums.phpfreaks.com/topic/217286-how-to-get-specific-rows-from-result-object/ Share on other sites More sharing options...
JustinK101 Posted October 30, 2010 Author Share Posted October 30, 2010 I came up with this. Any better way? $start_row = 2; $end_row = 6; $temp_rows = array(); $rows = array(); while($row = mysqli_fetch_object($result_obj)) { $temp_rows[] = $row; } for($i = $start_row; $i < $end_row; $i++) { $rows[] = $temp_rows[$i]; } print_r($rows); Link to comment https://forums.phpfreaks.com/topic/217286-how-to-get-specific-rows-from-result-object/#findComment-1128329 Share on other sites More sharing options...
ignace Posted October 30, 2010 Share Posted October 30, 2010 LIMIT 2, 4 http://dev.mysql.com/doc/refman/5.1/en/select.html Link to comment https://forums.phpfreaks.com/topic/217286-how-to-get-specific-rows-from-result-object/#findComment-1128330 Share on other sites More sharing options...
JustinK101 Posted October 30, 2010 Author Share Posted October 30, 2010 Yeah, cant do it at the db level, need to do in application code. Link to comment https://forums.phpfreaks.com/topic/217286-how-to-get-specific-rows-from-result-object/#findComment-1128331 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.