I've been working on a new page for blogs. The problem is when it outputs the page, it only shows one row when there is 2 rows in the table.
blogs.php looks like this:
<?php
/* $Id blogs.php */
define('IN_MYBB', 1);
$templatelist ="blogs,bloglist";
require "./global.php";
add_breadcrumb("Blogs", "blogs.php");
$query=$db->query("SELECT * FROM ".TABLE_PREFIX."blogs");
while ($blog = $db->fetch_array($query))
{
eval("\$bloglist = \"".$templates->get("bloglist")."\";");
}
eval("\$blogs = \"".$templates->get("blogs")."\";");
output_page($blogs);
?>
bloglist template
<tr><td class='trow1'><a href="/forums/member.php?action=profile&uid={$blog['uid']}" style="text-decoration:none">{$blog['username']}</a></td><td class="trow1"><a href="/forums/showblog.php?bid={$blog['bid']}" style="text-decoration:none">{$blog['topic']}</a></td></tr>
blogs template
<html><head><title>Blogs</title>{$headerinclude}</head><body>{$header}<table border='1' width='100%'><tr><th class='thead'>Author</th><th class='thead'>Topic</th></tr>{$bloglist}</table>{$footer}</body></html>
problem page
That's because your evaluating $blogs template outside the while() loop.
I moved the part where it evaluates $blogs template to inside the loop, but it still only shows one row.
Try this;
<?php
/* $Id blogs.php */
define('IN_MYBB', 1);
$templatelist ="blogs,bloglist";
require "./global.php";
add_breadcrumb("Blogs", "blogs.php");
$query=$db->query("SELECT * FROM ".TABLE_PREFIX."blogs");
$bloglist = "";
while ($blog = $db->fetch_array($query))
{
$bloguid = $blog['uid'];
$bloguname = $blog['username'];
$blogid = $blog['bid'];
$blogtopic = $blog['topic'];
eval("\$bloglist .= \"".$templates->get("bloglist")."\";");
}
eval("\$blogs = \"".$templates->get("blogs")."\";");
output_page($blogs);
?>
Now Change the bloglist template with this;
<tr>
<td class='trow1'>
<a href="/forums/member.php?action=profile&uid={$bloguid}" style="text-decoration:none">{$bloguname}
</a>
</td>
<td class="trow1">
<a href="/forums/showblog.php?bid={$blogid}" style="text-decoration:none">{$blogtopic}</a></td>
</tr>
It still only shows the first entry.
Then you probably have only one entry in your blog. The above edit should work
Here's the actual entries in the table, courtesy of the export function:
Database teamdime_mybb
Table structure for table mybb_blogs
Field Type Null Default
bid int(11) No
uid int(11) No
username text No
topic text No
message text No
Dumping data for table mybb_blogs
bid uid username topic message
2 214 slickmario 1st Attempt Nothing really to talk about. Just posting by first blog to see what happens.
1 1 Arceus Back To The Old Forum We are back at the old forum again. I had somehow broke at least one page on the VBulletin forum and was unable to repair it. MyBB is much easier to understand and I can even make new pages that integrate it without a huge amount of difficulty. I can even have it edit stats on the forum such as being able to track how many blog posts and social group posts a person has. I have worked for many hours to improve the layout and I'm a lot happier with it. It seems to be a more relaxed atmosphere than VBulletin provides. Themes are pretty easy to edit. Being able to know how to actually code in new features is also a bonus.
Table structure for table mybb_blogs
Field Type Null Default
bid int(11) No
uid int(11) No
username text No
topic text No
message text No
Try this?
<?php
/* $Id blogs.php */
define('IN_MYBB', 1);
$templatelist ="blogs,bloglist";
require "./global.php";
add_breadcrumb("Blogs", "blogs.php");
$query=$db->query("SELECT * FROM ".TABLE_PREFIX."blogs");
while ($blog = $db->fetch_array($query))
{
eval("\$bloglist .= \"".$templates->get("bloglist")."\";");
}
eval("\$blogs = \"".$templates->get("blogs")."\";");
output_page($blogs);
?>
That
should work anyway
what you had
eval("\$bloglist = \"".$templates->get("bloglist")."\";");
what it should be
eval("\$bloglist .= \"".$templates->get("bloglist")."\";");
you are missing the "." before the "=" so that it was not appending to the variable, but overwriting it. Even if you have 500 records, you'd still end up with one output since it was overwritten
That's what I changed too pavemen