PHP循环输出数据库表中字段内容

<div class="tab_title"><a href="/?p=bulletin">更多...</a><img src="/images/pin.gif" align="absmiddle" />最新公告</div>
<?
$str_sql=('SELECT * FROM messages WHERE type = 2 AND status is null ORDER BY createtime DESC limit 5' );
$result = $pdo->query($str_sql);

foreach($result as $r) {
print_array($r['createtime']);
print_array($r['title']);

?>
<table align="center" class="form-content" width="100%" style="border:0px solid #C0C0C0;float:left; " cellpadding="0" cellspacing="1">
<tr>
<td width="50%"><?$r['createtime']?></td>
<td width="50%"><a href="/?p=bulletin|<?$r['id']?>"><?$r['title']?></a></td>
</tr>
</table>
<? }
//exit;
?>
</div>
我现在能打印出$r['createtime内容,但是如何让它在table中显示出来?

使用<?=$var?>或者<?php echo $var;?>

<td width="50%"><?=$r['createtime']?></td>
<td width="50%"><a href="/?p=bulletin|<?=$r['id']?>"><?=$r['title']?></a></td>

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答
大家正在搜