thread list displaying wrong
i've changed some code thanks to help from mark on a different issue that this seems realtated to. so now i KNOW i have the timestamp. the problem is converting it to the user's time.
the code in question (altered to remove scrolling):
<?php
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
# stickied threads (will be added once i have display working. max or 10 for a total
# of 30 to a page)
$numsthreads=mysql_num_rows($findsthreads);
$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
$start=(($flength*$page)-$flength); # set start
$end=$flength*$page; # set 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 first thread to display
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']; # get the 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 it's locked, change lock
if($threadinf['locked']){ $lock='<img src=\"sitepics/locked.png\">'; }
# error reporting (last post time :: user's time display style :: gmt offset)
echo \"<br />$lpt :: $utds :: $gmtos\n\";
$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
}
?>
Quote: 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>
there's two echo statements to help in this. the print out i got from it was:
Quote: :: 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
POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.
m3rajk posted this at 18:21 — 19th September 2003.
They have: 461 posts
Joined: Jul 2003
issue found: lpt not set. == instead of =
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.