the code in question:
Code: Select all
function getthreads($fid, $db, $utds, $gmtos){ # get the threads in a forum
include("/home/joshua/includes/fyd.altincs.php"); # includes file for functions
$select='thread_id,curr_fid,sticky,locked,title,thread_auth,UNIX_TIMESTAMP(made),last_post_auth,UNIX_TIMESTAMP(last_post_time),amt_posts,orig_fid,post1id';
$findrthreads=mysql_query("SELECT $select FROM threads WHERE curr_fid='$fid' AND sticky='0' ORDER BY made DESC", $db); # find regular threads
$findsthreads=mysql_query("SELECT $select FROM threads WHERE curr_fid='$fid' AND sticky>'0' ORDER BY made DESC", $db); # find sticky threads
$numrthreads=mysql_num_rows($findrthreads); #regular threads
$numsthreads=mysql_num_rows($findsthreads); # stickied threads (will be added once i have display working. max or 10 for a total of 30 to a page)
$numthreads=$numrthreads+$numsthreads; # how many threads
$threads=''; # threads to return
$page=1; # page we're on
if(isset($_GET['page'])){ $page=$_GET['page']; } # set the page
if($numthreads===0){ # no threads
$threads=' <tr><td colspan="5">There are no posts in this Forum</td></tr>';
}else{ # there's threads
# flength (forum length)... set in includes. currently 30
$start=(($flength*$page)-$flength); # set start
$end=$flength*$page; # get initial end
if($end>$numrthreads){ $end=($numrthreads-($flength*($page-1))); } # set end
if($start!=0){ $jump=mysql_data_seek($findrthreads, $start) or die('database error seeking threads'); } # jump to the first thread (if needed)
for($i=0;$i<$end;$i++){ # for each thread we're gonna show
$threadinf=mysql_fetch_array($findrthreads); # get thread info
$tid=$threadinf['thread_id']; # thread id
$thread=$threadinf['title']; # get title
$started=$threadinf['made']; # when was it made (add later)
$posts=$threadinf['amt_posts']; # how many posts in thread?
$lpa=$threadinf['last_post_auth']; # who made the last post
$lpt==$threadinf['last_post_time']; # when was the last post
$lock='<img src="sitepics/unlocked.png">'; # set default locked
if($threadinf['locked']){ $lock='<img src="sitepics/locked.png">'; } # if it's locked, change lock
echo "<br />$lpt :: $utds :: $gmtos\n"; # error reporting (last post time :: user's time display style :: gmt offset)
$lpt=gmmktime($utds, ($lpt+($gmtos*60*60))); # change to user's time format/zone
echo "<br />$lpt\n"; # error reporting (is it right?)
$threads.=" <tr><td>$lock</td><td><a href="forums.php?fid=$fid&tid=$tid">$thread</a></td><td align="center">$posts</td><td>$lpa</td><td>$lpt</td></tr>\n"; #make thread listing
}
}
return $threads; # return thread list
}there's two echo statements to help in this. the print out i got from it was:mysql> select thread_id, UNIX_TIMESTAMP(last_post_time) from threads;
+-----------+--------------------------------+
| thread_id | UNIX_TIMESTAMP(last_post_time) |
+-----------+--------------------------------+
| 1 | 1063604865 |
| 2 | 1063605060 |
| 3 | 1063605206 |
| 4 | 1063605334 |
| 5 | 1063605380 |
+-----------+--------------------------------+
5 rows in set (0.00 sec)
mysql>
:: m/d/Y H:i:s :: -5.00
1062763236
1062763236 :: m/d/Y H:i:s :: -5.00
-14401
-14401 :: m/d/Y H:i:s :: -5.00
1061899176
1061899176 :: m/d/Y H:i:s :: -5.00
-14401
-14401 :: m/d/Y H:i:s :: -5.00
1061899176