Page 1 of 1

Custom PHP...

Posted: Sun Feb 15, 2009 9:33 pm
by kevincon
I have a custom index setup for my forum. Looks like this...

Code: Select all

    <?php
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);

    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();

    page_header('Home');

    $template->set_filenames(array(
        'body' => 'home_body.html',
    ));

    make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
    page_footer();
    ?>
I changed it to this...

Code: Select all

    <?php
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);

    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();

    page_header('Home');

    $template->set_filenames(array(
        'body' => 'home_body.html',
    ));

    make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
    page_footer();
    ?>
	
	<?php
	

						$query = "SELECT * FROM home_body WHERE username='kevin'";
						
						$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());

						
						if (mysql_num_rows($result) > 0) {
    	
						while($row = mysql_fetch_array($result)) {
						echo $row["content"];
						    					}
						} else {

    					echo "No rows found!";
						}
						
	?>

The PHP i put in doesn't wanna show up, How else could i pull up information from a table on my index?
How could i get my own custom PHP to show up on my index page?
I also tried to put PHP on the template file in the STYLE but that proved no good...

Re: Custom PHP...

Posted: Sun Feb 15, 2009 9:36 pm
by John P
You should use the dbal for your queries and assign the output to $template.

Re: Custom PHP...

Posted: Sun Feb 15, 2009 9:42 pm
by kevincon
I need you to be more specific...

Re: Custom PHP...

Posted: Sun Feb 15, 2009 9:53 pm
by Mr. Bond
kevincon wrote:I need you to be more specific...
The DBAL is the Database Abstraction Layer that phpBB3 uses, and Stef775 is saying you should use the template engine to output the data. These links may help :)

Re: Custom PHP...

Posted: Sun Feb 15, 2009 9:55 pm
by kevincon
I will look into this, Thank you very much. :D

Re: Custom PHP...

Posted: Sun Feb 15, 2009 10:03 pm
by kevincon
I'm looking at this wiki, and wondering what the hell am i looking at. I'm still having trouble, How could i use the script i made, basically pull up the info from my table...Any one want to help me figure this out?

Re: Custom PHP...

Posted: Sun Feb 15, 2009 11:36 pm
by kevincon
Basically my question is, how could i pull up the information on a table in the phpbb database. And the perhaps show it on the template? I'm very lost.