Hi I would like to do something like the following: I have a table that contains a bunch of info at various "stages". To optimize the load on the db, I was thinking it would be better to do a "select * from table" , and then use PHP to sort through the results, rather than have 3 SQL's with "where status="xxx" ".
There are essentially 3 "stages" or "states" at which the data in the table can be sorted, so I would need to loop through the array 3 times in order to display the entire contents of the table ordered by the 3 statges. This is my first attempt: $sql_it = 'select * from tickets '; $result_it = mysql_query($sql_it); echo 'New Tickets <br>'; $count = 0; while ($myrow_it = mysql_fetch_assoc($result_it)) { $status = $myrow_it["status"]; if ($status == "OPEN") { $company = $myrow_it["company"]; $title = $myrow_it["title"]; $content = $myrow_it["content"]; echo $company.' :: '.$title.' :: '.$content.'<br>'; $count++; } } echo 'Total New:'.$count.'<br>'; echo 'Current Tickets <br>'; while ($myrow_it = mysql_fetch_assoc($result_it)) { $status = $myrow_it["status"]; if ($status == "CURRENT") { $company = $myrow_it["company"]; $title = $myrow_it["title"]; $content = $myrow_it["content"]; echo $company.' :: '.$title.' :: '.$content.'<br>'; } } echo 'Old Tickets <br>'; while ($myrow_it = mysql_fetch_assoc($result_it)) { $status = $myrow_it["status"]; if ($status == "OLD") { $company = $myrow_it["company"]; $title = $myrow_it["title"]; $content = $myrow_it["content"]; echo $company.' :: '.$title.' :: '.$content.'<br>'; } } Now, obviously this only echoes the first part, as it seems the array is at the end when it tries to loop through again. I tried a reset($myrow_it) , but it drops an error about $myrow_it not being an array. I'm not sure if my logic here is correct. Is this the way to "re-loop" the array? Hope I explained what I am trying to do well enough. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php