0
用於辯論和註釋的數據庫表是相同的。看來$ title和$ date不起作用。我怎樣才能從兩者中獲取信息,並按日期排序?mysql接收並比較來自多個表的數據
<?php
$showwall = mysql_query("(SELECT * FROM debat WHERE user='$user') UNION (SELECT * FROM comments WHERE user='$user') ORDER BY date LIMIT 0, 25");
$results = array();
while($wall = mysql_fetch_array($showwall, MYSQL_ASSOC)){ // Line 21
$results[] = $wall;
<li class="comment">
<div class="comment">
<div class="comment-author vcard user frame">
<?php echo "<a href=view.php?action=view&ID=".$wall['ID']."><img src=images/avatar/".$select['avatar']." class=avatar avatar-70 photo height=70 width=70 /></a>"; ?>
</div>
<div class="message">
<span class="reply-link"><?php echo "<a href=view.php?action=edit&ID=".$wall['ID'].">"; ?> Edit </a></span>
<div class="info">
<h2><?php echo $wall['title']; ?></h2>
<span class="meta">
<?php
$date->setTimestamp($wall['date']);
echo "Dato: ";
echo $date->format('d-m-Y') . "\n";
echo "Kl: ";
echo $date->format('H:i:s') . "\n";
?>
</span>
</div>
<div class="comment-body ">
<p><?php echo $wall['comment']; ?></p>
</div>
</div>
</div>
</li>
<?php } ?>
我想添加另一個數據庫加載,似乎留下一個空白的結果。
$showwall = @mysql_query("(SELECT * FROM debat WHERE user='$user') UNION (SELECT * FROM comments WHERE user='$user') UNION (SELECT * FROM nyheder WHERE user='$user') ORDER BY date LIMIT 0, 25");
數據庫包含具有相同名稱的表,但其中一些具有比其他字段更多的字段。所以這不是正確的做法嗎?
開始通過去除所有@誤差抑制 – 2013-12-18 18:02:00
警告:mysql_fetch_array()預計參數1是資源,在布爾的public_html/wall.php給出在第17行 第17行:而($壁= mysql_fetch_array($ showwall) ){?> – Kingfox
querry失敗,調試thtat – 2013-12-18 18:14:49