PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
$getarticle = $connector->query('SELECT ID,title,creator,created,last_edited FROM cmsarticles ORDER BY created ASC');
$articles = $connector->fetchArray($getarticle);
$creator = $connector->query('SELECT user FROM cmsusers');
$creators = $connector->fetchArray($creator);
while ($articles = $connector->fetchArray($getarticle))
{
echo '<p><a href="article.php?id='.$articles['ID'].'&act=v">';
echo $articles['title'];
echo '</a>';
echo '<br>Created by: '
.$creators['user'].' | Created on: '
.substr($articles['created'], 0, 10).' | Last edited: '
.substr($articles['last_edited'], 0, 10);
echo '</p>';
}
?>
This does as expected except that it does not pull in all records. If I do a DESC order then the first record is not displayed but if I do as above and do a ASC then I do not get the last record. If I do neither then I may as well do a DESC.
gazzieh wrote:$getarticle = $connector->query('SELECT ID,title,creator,created,last_edited FROM cmsarticles ORDER BY created ASC');
$articles = $connector->fetchArray($getarticle);
because in the line above you are getting the first record of your record set and you are not doing nothing with it .... you are getting and processing the remaining records in the while loop.
your query is getting all the records the problem is how are you processing the results