ryan king Posted January 26, 2009 Share Posted January 26, 2009 I have a column in my database called BAND_UPDATE that records a users last login time. I am now displaying users within a certain zipcode radius. I would like to also have it order them by their last login time. How would I go about doing this? <?php $row_count = 0; $z = new zipcode_class; $zips = $z->get_zips_in_range($_GET['zip_code'], $_GET['miles'], _ZIPS_SORT_BY_DISTANCE_ASC, true); // add searched for zip to $zips array $zips[$_GET['zip_code']] = 0; $row_count = 0; // this is just to initialise the variable: $result_array = array(); // first we gather all the results into a single array: foreach ($zips as $key => $value){ //find all locations within range using returned zipcode values $sql_events = mysql_query("SELECT * FROM jamroom_band_info WHERE band_zipcode='$key'") or die (mysql_error()); while ($row = mysql_fetch_array($sql_events)) { // we just add this row to the array: $result_array[] = $row;} } // config i guess $entriesperline=4; $counter=1; print "<table>"; // loop through each result row. $i = 0; foreach ($result_array As $row){ if($counter%$entriesperline==1 && $i < 50){ print "<tr><td align='center'><div class='body-zip'><a href=\"members/{$row['band_id']}\">{$row['band_name']}</a><br><a href=\"members/{$row['band_id']}\"><img border='0' src=\"image.php?band_id={$row['band_id']}&mode=band_image&width=100&theme=Sage\">{$row['band_image']}</a></div></td>"; }else if($counter%$entriesperline==0 && $i < 50){ print "<td align='center'><div class='body-zip'><a href=\"members/{$row['band_id']}\">{$row['band_name']}</a><br><a href=\"members/{$row['band_id']}\"><img border='0' src=\"image.php?band_id={$row['band_id']}&mode=band_image&width=100&theme=Sage\">{$row['band_image']}</a></td></div></tr>"; }else if($i < 50){ print "<td align='center'><div class='body-zip'><a href=\"members/{$row['band_id']}\">{$row['band_name']}</a><br><a href=\"members/{$row['band_id']}\"><img border='0' src=\"image.php?band_id={$row['band_id']}&mode=band_image&width=100&theme=Sage\">{$row['band_image']}</a></div></td>"; } $counter++; $i++; } //exit loop if($counter%$entriesperline!=0){ print "</tr>"; } print "</table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/142421-solved-order-by-last-login/ Share on other sites More sharing options...
MadTechie Posted January 26, 2009 Share Posted January 26, 2009 ORDER BY BAND_UPDATE DESC $sql_events = mysql_query("SELECT * FROM jamroom_band_info WHERE band_zipcode='$key' ORDER BY BAND_UPDATE DESC ") or die (mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/142421-solved-order-by-last-login/#findComment-746197 Share on other sites More sharing options...
ryan king Posted January 26, 2009 Author Share Posted January 26, 2009 thanks..thats what I need! Quote Link to comment https://forums.phpfreaks.com/topic/142421-solved-order-by-last-login/#findComment-746222 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.