Not Solved [Page Manager] Share your custom pages
Not Solved
Thanks for the reply.
I'm going to test it out now.

I tried this one

<?php 
global $db;
$data = $db->simple_select('userfields, '*');

while($info = mysql_fetch_array( $data )) 
{
$var .= " " . $info['fid6'] . " ";
}
?>
But this gives me an white screen

I also tried this one
<?php
global $db;
$data = $db->simple_select('userfields', '*');

global $headerinclude, $header, $footer;

$var = '';

while($info = mysql_fetch_array( $data )) 
{
$var .= " " . $info['fid6'] . " ";
}

$templates->cache['page'] = '<html>
    <head>
        <title>{$pages[\'name\']} - {$settings[\'bbname\']}</title>
        {$headerinclude}
    </head>
    <body>
        {$header}
        {$pages[\'template\']}
        {$footer}
    </body>
</html>';

eval("\$page= \"".$templates->get("page")."\";");
output_page($page);
exit; 
?>
But also a white screen.

Am I doing something wrong?

Thanks for the replys

I'm using mybb 1.6*
Reply
Not Solved
Use $db->fetch_array(), not mysql_fetch_array(). No sure if that is the problem though.
Reply
Not Solved
(2014-06-01, 11:11 PM)Omar G. Wrote: Use $db->fetch_array(), not mysql_fetch_array(). No sure if that is the problem though.

Still a white screen.

This is my original code
<?php 
 // Connects to your Database 
 mysql_connect("localhost", "mybb_mybbcct", "pass") or die(mysql_error()); 
 mysql_select_db("mybb_mybbcct") or die(mysql_error());
 $data = mysql_query("SELECT * FROM cct_userfields") 
 or die(mysql_error());
 
 while($info = mysql_fetch_array( $data )) 
 {
 Print " ".$info['fid6'] . " ";
 }
?>

This is the code I now made with the changes
<?php
global $db;
$data = $db->simple_select('userfields', '*');

global $headerinclude, $header, $footer;

$var = '';

while($db->fetch_array( $data )) 
{
$var .= " " . $info['fid6'] . " ";
}

$templates->cache['page'] = '<html>
    <head>
        <title>{$pages[\'name\']} - {$settings[\'bbname\']}</title>
        {$headerinclude}
    </head>
    <body>
        {$header}
        {$pages[\'template\']}
        {$footer}
    </body>
</html>';

eval("\$page= \"".$templates->get("page")."\";");
output_page($page);
exit; 
?>

Can you see why this is not working?
Reply
Not Solved
Try the following:
<?php
global $db;
$data = $db->simple_select('userfields', '*');

global $headerinclude, $header, $footer, $settings;

$var = '';

while($info = $db->fetch_array( $data )) 
{
$var .= " " . htmlspecialchars_uni($info['fid6']) . " ";
}

$templates->cache['page'] = '<html>
    <head>
        <title>Page Title - {$settings[\'bbname\']}</title>
        {$headerinclude}
    </head>
    <body>
        {$header}
        {$var}
        {$footer}
    </body>
</html>';

global $templates;

eval("\$page= \"".$templates->get("page")."\";");
output_page($page);
exit; 
?>

$templates / $settings variable was not a global.
Reply
Not Solved
Ok nice with the changes you made and some of mine I got it to work. Now it shows the value out of the db.

This is the code:
<?php

global $db, $headerinclude, $header, $theme, $footer, $templates, $lang;
$data = $db->simple_select('userfields', '*');
$var = '';

while($info = $db->fetch_array( $data )) 
{
$var .= " " . htmlspecialchars_uni($info['fid6']) . " ";
}

$template = '<html>
<head>
<title>' . $pages['name'] . '</title>
{$headerinclude}
</head>
<body>
{$header}
{$errors}
{$var}
{$footer}
</body>
</html>';

$template = str_replace("\'", "'", addslashes($template));

add_breadcrumb($pages['name']);

eval("\$page = \"" . $template . "\";");

output_page($page);

?>

Now I only have to put the output in a table.

Only thing I want to ask you is how do I put a separator between the output.

now it does this:

12345 12345 12345 and I want it to be like this 12345, 12345, 12345,.... and so on
Reply
Not Solved
Replace:
$var .= " " . htmlspecialchars_uni($info['fid6']) . " ";

With:
$comma = $var ? ',' : '':
$var .= $comma." " . htmlspecialchars_uni($info['fid6']) . " ";
Reply
Not Solved
Ok sorry that works great only needed to change the last : to ; behind the comma line.

Then I have one last thing. How do I leave out the empty cells? I have allot of empty cells and now it does this.

, 985192750 , , , 123456789 , , , , , , , , , , , ,

It only needs to put a comma behind a filled cell.
Reply
Not Solved
Replace:
$var .= $comma." " . htmlspecialchars_uni($info['fid6']) . " ";

With:
$var .= empty($info['fid6']) ? '' : $comma." " . htmlspecialchars_uni($info['fid6']) . " " ;

It will add the field to $var only if $info['fid6'] is not empty.
Reply
Not Solved
Nice thanks very much. It's working like a charm.
I will comment everything out and will share it here so others can use it also.

Here is the example page .

Tomorrow I will upload it.

Again Thanks Omar G.
Reply
Not Solved
I imported the banlist.xml file but when I try to go to it on my site, it is just a blank page.
Here is the link to the page: http://openmarketforums.co.uk/misc.php?page=banlist
How do I fix this?
[Image: misc.php?page=signature]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)