View Single Post
Old 10-23-2004, 05:04 PM   #24 (permalink)
Redline
PHP Student
 
Join Date: Oct 2004
Location: Forest Grove, OR
Posts: 151
Redline is on a distinguished road
Send a message via AIM to Redline Send a message via MSN to Redline
Sure thing, here is my insert_news() function straight from my website

PHP Code:
    function insert_news($num_threads$width$margin
    {
        global 
$root$tpl_name$tpl_path$forum_path$max_news;
        
$query "SELECT topic_first_post_id, topic_poster, topic_time, topic_id FROM phpbb_topics WHERE forum_id = '6' ORDER BY topic_time DESC";
        
$result mysql_query($query) or die("Error: ".mysql_error());

        
$num_rows mysql_affected_rows();



        if (
$max_news $num_rows || $num_threads == 0)
            
$x $num_rows;
        else
            
$x $max_news;




        for (
$i 1$i <= $x$i++)
        {
            
$post[$i] = mysql_fetch_row($result);                
        }

        
$i 0;
        foreach(
$post as $value)
        {
            
$i++;
            
$post_id $value[0];
            
$topic_id $value[3];
            
            
$query "SELECT post_subject, post_text FROM phpbb_posts_text WHERE post_id = '".$post_id."'";
            
$result mysql_query($query) or die("ERROR: ".mysql_error());
            
$data mysql_fetch_row($result);
            
            
$news_subject $data[0];
            
$news_text $data[1];
            
$post_time $post[$i][2];

            
$query "SELECT username FROM phpbb_users WHERE user_id = '".$post[$i][1]."'";
            
$result mysql_query($query);
            
$data mysql_fetch_row($result);

            
$poster $data[0];


            include 
$tpl_path "news.php";

        }
    } 
This function pulls $max_news threads from the top of my websites News forum. It then parses the information for that post and posts it on the index of my website with a dynamically created background for each post. $max_news is an integer in the mysql database that sets the maximum number of news posts to be posted to the website. The graphical construction of the news posts are controlled by the news.php template file that is included for each post.

My website is tied very tightly to my PHPBb2 forums. The members list in the navbar is pulled from the Clan Members usergroup on the forums, as is the information in their profiles. If you'd like to look at my website for a better idea of how things are setup, here it is: Apocalyptic Visions

I just started learning PHP in August and this website is my first real project. It's ran entirely on PHP and a MySQL database. Hope this helps you out, sorry about the messy code. I even had to look over the function for a few minutes to remember exactly how it worked lol
__________________
Current Project

Last edited by Redline; 10-23-2004 at 07:08 PM.
Redline is offline   Reply With Quote