the database tables for debat and comments are the same. it seems that $title and $date isnt working. how can i get the information from both, and order by date?
<?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') . "
";
echo "Kl: ";
echo $date->format('H:i:s') . "
";
?>
</span>
</div>
<div class="comment-body ">
<p><?php echo $wall['comment']; ?></p>
</div>
</div>
</div>
</li>
<?php } ?>
I want to add another database to load from, it seems to leave a blank result.
$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");
the database contains tables with the same names, but some have more fields than others. So this is isnt the right way to do it?