ROM `shouts`"); while($data=mysql_fetch_array($sql)){ //counts every row $counting=$counting+1; } //end while
// if the count comes back greater than 10, then we select the last // 10 shouts for display.
if($counting>10){ $countlessten=$counting-9; $sql=mysql_query("SELECT * FROM `shouts` ORDER BY `shouts`.`id` ASC LIMIT $countlessten,10"); }else{ //else it doesn''t matter, there''s less than 10! $sql=mysql_query("SELECT * FROM `shouts` ORDER BY `shouts`.`id` ASC LIMIT 10"); } while($data=mysql_fetch_array($sql)){ //my timestamp field in the database is basically useless to me unless //I parse it. The following code parses the timestamp into things I //can use. $timestamp=$data[''timestamp'']; $postedyear=substr($timestamp,0,4); $postedmonth=substr($timestamp,5,2); $postedday=substr($timestamp,8,2); $postedtime=substr($timestamp,11,5); $newpostedtime=""; $nomilitary=substr($postedtime,0,2);
// the hour is greater than 12, so we need to switch back to 1-12 and // add a "pm"
if($nomilitary>=13){ $nomilitary=$nomilitary-12; $newpostedtime=$nomilitary; $newpostedtime.=":"; $newpostedtime.=substr($postedtime,3,2) ; $newpostedtime.=" pm"; } if($newpostedtime!=""){ $postedtime=$newpostedtime; }else{ $postedtime.=" am"; } //now that we have the time, let''s get the shout and the shouter