G'day joelvardy,
I two am trying to get this works. Firstly I have changed the 'cmsarticles' to 'news'. I have also added a field in the 'news' table called author which holds the authors/users unique ID. What I am trying to do, which I believe is what you are also trying to do is to output a list of news articles and their individual authors. The code I am playing with at the moment is:
PHP Code:
<?php
// Require the database class
require_once('includes/DbConnector.php');
// Create an object (instance) of the DbConnector
$connector = new DbConnector();
// Execute the query to retrieve articles
$result = $connector->query('SELECT ID,title,tagline FROM news ORDER BY ID DESC LIMIT 0,5');
// Get an array containing the results.
// Loop for each item in that array
while ($row = $connector->fetchArray($result)){
$sql = $connector->query("SELECT ID, user FROM users WHERE '".$row[author]."' = ID");
while ($rowauth = $connector->fetchArray($sql)){
echo '<h3>';
echo $row['title'];
echo '</h3>';
echo '<p>';
echo $rowauth['user'];
echo '</p>';
echo '<p>';
echo $row['thenews'];
echo '</p><hr />';
}
}
?>
I have however, hit a wall and can't seem to work out a fix.
Any help is greatly appreciated.
Marzar