MyBB Community Forums

Full Version: Problem with fetch_array
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Now it works, thanks. I can't believe I forgot to put a period before the equal sign.
(2011-04-06, 03:38 PM)euantor Wrote: [ -> ]That's what I changed too pavemen Wink

by 4 minutes. if I didn't spend the time eating those two Twinkies for breakfast, I would have it posted first Sad
(2011-04-06, 03:08 PM)Yaldaram Wrote: [ -> ]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);
?>

And I posted this same thing minutes ago Sad
(2011-04-06, 03:47 PM)pavemen Wrote: [ -> ]
(2011-04-06, 03:38 PM)euantor Wrote: [ -> ]That's what I changed too pavemen Wink

by 4 minutes. if I didn't spend the time eating those two Twinkies for breakfast, I would have it posted first Sad

Wink May I ask though, what on earth is a "Twinkie"? haha

(2011-04-06, 03:51 PM)Yaldaram Wrote: [ -> ]
(2011-04-06, 03:08 PM)Yaldaram Wrote: [ -> ]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);
?>

And I posted this same thing minutes ago Sad

He said that yours "didn't work" though for some reason. Also, may I ask why you did all that

$bloguid = $blog['uid'];
$bloguname = $blog['username'];
$blogid = $blog['bid'];
$blogtopic = $blog['topic'];

? Seems useless to me.
(2011-04-06, 04:02 PM)euantor Wrote: [ -> ]Wink May I ask though, what on earth is a "Twinkie"? haha

I realize you are not in the US, but you've never seen the ZombieLand movie?

http://en.wikipedia.org/wiki/Twinkie
(2011-04-06, 04:02 PM)euantor Wrote: [ -> ]Also, may I ask why you did all that

$bloguid = $blog['uid'];
$bloguname = $blog['username'];
$blogid = $blog['bid'];
$blogtopic = $blog['topic'];

? Seems useless to me.

No, its better to assign variables inside the while loop if you want to evaluate a template. However it should work with the other way as well.
(2011-04-06, 05:52 PM)pavemen Wrote: [ -> ]
(2011-04-06, 04:02 PM)euantor Wrote: [ -> ]Wink May I ask though, what on earth is a "Twinkie"? haha

I realize you are not in the US, but you've never seen the ZombieLand movie?

http://en.wikipedia.org/wiki/Twinkie

Nope, never seen it. Those do look good though :O

(2011-04-06, 05:57 PM)Yaldaram Wrote: [ -> ]
(2011-04-06, 04:02 PM)euantor Wrote: [ -> ]Also, may I ask why you did all that

$bloguid = $blog['uid'];
$bloguname = $blog['username'];
$blogid = $blog['bid'];
$blogtopic = $blog['topic'];

? Seems useless to me.

No, its better to assign variables inside the while loop if you want to evaluate a template. However it should work with the other way as well.

I've actually never heard that. I like to keep variable definitions to a minimum, but fair enough.

/off topic
Pages: 1 2