Please help, a bit new to this!
I've got two databases and I'm trying to look with values from one table in
one database and then look up a name from the other database, the two tables
are linked where 'postedby' in my newsdb database refers to 'ID' in my
tblemployees table in my basedb database.
All I get is one name shown and 6 records where there are actually 7.
Any help would be greatly appreciated.
Kind Regards,
Matthew
Code Below:
--------------------------------------------------------------
<?php
require_once('Connections/newsdb.php');
require_once('Connections/basedb.php');
mysql_select_db($database_newsdb, $newsdb);
$res_newsdb = mysql_query("SELECT * FROM tblnews ORDER BY newsdate DESC");
mysql_select_db($database_basedb, $basedb);
$row_newsdb=mysql_fetch_object($res_newsdb);
$res_basedb=mysql_query("SELECT * from tblemployees WHERE
ID=$row_newsdb->postedby");
?>
<html>
<link href="body01.css" rel="stylesheet" type="text/css">
<body>
<table width="500" border="0" class="body01" style='BORDER-COLLAPSE:
collapse'>
<tr>
<td>Latest News:</td>
<td><div align="right"><a href="../phpbb" target="_MainFrame">Bulletin
Board</a></div></td>
</tr>
</table>
<p class="body01">
<?php
echo ("<TABLE BORDER='1' WIDTH=450 style='BORDER-COLLAPSE: collapse'>");
$rows=1;
while($rows <= 10)
{
$res_news = mysql_fetch_array($res_newsdb);
$res_base = mysql_fetch_array($res_basedb);
$ndate = $res_news['newsdate'];
echo ('<TR><TD><FONT SIZE=-2><div align="center">' . $ndate .
'</div></FONT></TD><TD>' .
$res_news['news']) . '</TD><TD>' .
$res_base['IDname'] . '</TD></TR>';
$rows++;
}
mysql_free_result($res_newsdb);
echo('</TABLE>');
echo("<BR /><P><A HREF='addnews.php'>Add news</A></P>");
?>
</p>
<p><span class="body01">To email the website manager click </p>
</body>
</html>
---------------------------------------------------------------------