zxnet2k Posted December 9, 2009 Share Posted December 9, 2009 Heya Guys, New to the forum and have been battling for this problem for quite a while with no luck, thought I would call in expert help Basically I have the following PHP code that runs from a require statement on a different page, and it is designed to pull the last 10 posts from the DB table and display title, date short extract etc. <?php $sql = "select id, title, content, date from posts where active = '1' order by date DESC"; $result = mysql_query($sql,$conn) or die(mysql_error()); $num_rows = mysql_num_rows($result); if ($num_rows != 0) { $n = 0; while($row = mysql_fetch_array($result) or die(mysql_error())){ $title = $row['title']; echo $title; if ($n < 10) { echo "<div class=\"topTenRow\">"; $id = $row['id']; $date=date("d/m/Y", strtotime($row["date"])); $title = $row['title']; $content = $row['content']; $text = $content; $text = substr($text,0,120); $text = substr($text,0,strrpos($text,' ')); $text = $text."..."; echo "<div class=\"TTdate\">$date</div>"; echo "<strong>" . $title . "</strong>"; echo "<a class=\"topTenLink\" href=\"posts.php?id=$id\"><img alt=\"Read More\" src=\"images/buttons/btnReadMore.png\"/></a>"; echo "$text </div>"; $n = $n + 1; } } } ?> The strange thing is that the code executes on the page and the require statement show the expected result, however all the rest of the code on the initial page after the require doesn't show anything, and even the source code stops there as well (when viewing it in a browser) Any ideas if there is something in the code above which is causing it, or could it be a problem elsewhere - anyone ever had this issue before? I would appreciate all recommendations and suggestions, even if they don't relate directly to the problem above Quote Link to comment Share on other sites More sharing options...
zxnet2k Posted December 9, 2009 Author Share Posted December 9, 2009 Hi guys, just as I post it I figure it out - typical! For anyone wondering there was a jquery conflict issue with another part of the page. Seeing as how the post is still up, can anyone comment on the code I have used above? Is this an effective way of pulling a top ten most recent posts box or could it be done differently? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.