ip กับวันที่ไม่แมตช์กับชื่อตรงคอลัมน์สุดท้าย last reply ช่วยดูให้ที่ครับ
รู้สึกเหมือนจะผิดที่ array 2 มิติ $lastreply แต่ไม่รู้จะแก้ยังไงครับ
Code (PHP)
<?php
$keyword = $_GET[keyword];
$db = new Mysql();
$lastreply = array($row[topic_id][0],$row[topic_id][1],$row[topic_id][2]);
// last reply
$sql = "SELECT reply.topic_id,reply.reply_poster,reply.reply_date,reply.reply_ip,reply.reply_id
FROM reply,
(SELECT max(reply_id) as maxid,topic_id
FROM reply
GROUP BY topic_id) maxresults
WHERE reply.topic_id = maxresults.topic_id
AND reply.reply_id= maxresults.maxid";
$db->execute($sql);
$num = $db->numrow();
for ($i=1; $i<=$num; $i++){
$row = $db->movenext();
$lastreply[$row[topic_id][0]] = $row[reply_poster];
$lastreply[$row[topic_id][1]] = $row[reply_ip];
$lastreply[$row[topic_id][2]] = $row[reply_date];
}
$sql = "select * from topic";
if ($keyword != "")
$sql .= " where topic_name like '%$keyword%'";
$sql .= " order by topic_date desc";
$db->execute($sql);
$total = $db->numrow();
if ($total==0 && $keyword!="")
alertgo("Not Found Data !!!!","index.php");
if ($total==0)
exit("Not Found data !!!!");
$total_page = ceil($total/PAGESIZE);
$page = $_GET[page];
if ($page=="")
$page = 1;
$start = ($page-1)*PAGESIZE;
$sql .= " limit $start,".PAGESIZE;
$db->execute($sql);
$num = $db->numrow();
?>
<?php
for ($i=1; $i<=$num; $i++){
$row = $db->movenext();
?>
<tr bgcolor="<?php echo $color=($i%2==1)?'#FFFFFF':'#FFEFFF'; ?>" onmouseover="javascript:this.bgColor='#CCCCCC'" onmouseout="javascript:this.bgColor='<?php echo $color ?>'">
<td><a href="add_view.php?t=<?php echo $row[topic_id] ?>" target="_blank">[#<?php echo str_pad($row[topic_id],5,"0",STR_PAD_LEFT) ?>] <?php echo $row[topic_name] ?></a><br />
Date : <?php echo $row[topic_date] ?></td>
<td><?php echo $row[topic_poster] ?> <br /><small>(Ip : <?php $ip = explode(".",$row[topic_ip]); echo "$ip[0].$ip[1].$ip[2].xxx"; ?>)</small></td>
<td align="center"><?php echo $row[topic_view] ?></td>
<td align="center"><?php echo $row[topic_reply] ?></td>
<td><?php echo $lastreply[$row[topic_id][0]] ?> [<?php echo $lastreply[$row[topic_id][1]] ?>]<br />
Date:<?php echo $lastreply[$row[topic_id][2]] ?></td>
</tr>
<?php } ?>
Tag : PHP, MySQL
Date :
2011-08-13 00:03:29
By :
pavich
View :
793
Reply :
1
Load balance : Server 05