Jump to content

Forum Help


twsowerby

Recommended Posts

Hi guys, I'm new to PHP and need a bit of help.

 

Trying to make a forum from scratch as part of my university coursework. Basic functionality is required ie a list of forum categories and within those categories a list of threads with replies.

 

I need some advice on how to make a new thread appear under its relevant forum category when it is created by a user.

 

For example, i need threads about action movies to appear inside the action movie category when they get created. I know i can set the threads 'category id' but a typical user wont know what the category id is so it needs to be set automatically based on what category the user is creating the thread in.

 

Any help would be greatly appreciated.

 

Thanks

Link to comment
Share on other sites

Well I'm not a complete newcomer, Ive pretty much learned the basics. For the moment it doesnt need any user authorisation. Database structure at the moment consists of a table holding all the category ids, titles, descriptions and then a table with all the posts in it. New threads are defined by having a parentid of 0, whereas replies to threads have the postid of the thread they are replying to as their parent id.

 

Does that make sense? I am open to all suggestions, so feel free to order me around if you have a better way of doing it.

 

Cheers,

 

Tom

Link to comment
Share on other sites

Ok, well you will need several scripts... a viewCat script to load the categories, this can generally be the index.php page. Then you will need a viewForum script to view message headers inside each category. Next a viewThread script to read individual posts. Lastly, you will need a posting script for new posts or replys. Take them one at a time and stay focused.

 

You say you have the cat ID's setup in your database. Do you have a script yet which displays these categories?

 

PhREEEk

Link to comment
Share on other sites

Yeah this is my code for viewing the categories, I am going to put a thread count in later but that shouldnt affect anything at the moment i dont think.

 

<?php 

include "sqlconnect.php"; //mysql db connection here

print "<link rel='stylesheet' href='style.css' type='text/css'>";

print "<A href='post.php'>New Topic</a><br>";

print "<table class='maintable'>";

print "
<tr class='headline'>
<td width=50%>Genre</td>
<td width=20%>Description</td>
<td>Moderator ID</td>
</tr>";

$getcat="select * from forum_genres order by genre_id DESC"; 

$getcat2=mysql_query($getcat) or die("Could not get threads");

while($getcat3=mysql_fetch_array($getcat2))

{

print "
<tr class='mainrow'>
<td><a href='viewThreads.php'>$getcat3[genre_title]</a></td>
<td>$getcat3[genre_desc]</td>
<td>$getcat3[genre_mod]</td>
</tr>
";

}

print "</table>";

?>  

 

Link to comment
Share on other sites

ok, and how is that working for you? Are there any issues to be worked out?

 

>I am going to put a thread count in later but that shouldnt affect anything at the moment

 

Yeah.. keep it as absolutely simple as possible while 'framing' it out. Add in the luxury items once you have a solid chassis.

 

= )

 

PhREEEk

Link to comment
Share on other sites

Well it works, it displays the categories fine. I also have the viewForum page working, which uses almost identical code and that works fine as well. But I need to get it so that when i click on the category I want, it only displays the message headers from that category on the viewForum page. Any ideas?

 

I also have the script which creates a new thread:

 

<?php

include "sqlconnect.php"; //connection string

print "<link rel='stylesheet' href='style.css' type='text/css'>";

print "<table class='maintables'>";

print "<tr class='headline'><td>Post a message</td></tr>";

print "<tr class='maintables'><td>";

if(isset($_POST['submit']))

{

   $name=$_POST['name'];

   $yourpost=$_POST['yourpost'];

   $title=$_POST['title'];

   if(strlen($name)<1)

   {

      print "You did not type in a name."; //no name entered

   }

   else if(strlen($yourpost)<1)

   {

      print "You did not type in a post."; //no post entered

   }

   else if(strlen($title)<1)

   {

      print "You did not enter a title."; //no subject entered

   }

   else

   {

      $thedate=date("U"); //get unix timestamp

      $displaytime=date("F j, Y, g:i a");

      //we now strip HTML injections

      $subject=strip_tags($title);

      $name=strip_tags($name);

      $yourpost=strip_tags($yourpost); 

      $insertpost="INSERT INTO forum_posts(author,title,post,showtime,realtime,lastposter) values('$name','$title','$yourpost','$displaytime','$thedate','$name')";

      mysql_query($insertpost) or die("Could not insert post"); //insert post

      print "Message posted, go back to <A href='index.php'>Forum</a>.";

   }



}

else

{

   print "<form action='post.php' method='post'>";

   print "Your name:<br>";

   print "<input type='text' name='name' size='20'><br>";

   print "Title:<br>";

   print "<input type='text' name='title' size='20'><br>";

   print "Your message:<br>";

   print "<textarea name='yourpost' rows='5' cols='40'></textarea><br>";

   print "<input type='submit' name='submit' value='submit'></form>";



}

print "</td></tr></table>";

?>

 

But I have no idea how to enure that the new thread is added under the appropriate category, do you have any suggestions on how to do this?

 

 

Yeah.. keep it as absolutely simple as possible while 'framing' it out. Add in the luxury items once you have a solid chassis.

 

 

Yeah, simple is good =)

 

Tom

Link to comment
Share on other sites

Each post will need a unique postid (use auto increment here) and the catid it was posted to. The catid should be witnin the $_POST data as a hidden field. Date("U") can simply be time() - same results. You don't need the field lastposter. We can get that info any time we need to with a simple query.

 

PhREEEk

Link to comment
Share on other sites

Guess I missed the question... lol

 

You need to create hyperlinks on the main category page (did you name it index.php? or what?) for each category header. These hyperlinks will direct to the viewForum script and pass through a Forum ID. The viewForum script will then ask MySQL for a list of all messages for that Forum ID, and we'll build a table to display all the messages.

 

PhREEEk

Link to comment
Share on other sites

lol im confused enough as it is without you missing questions!  :P

 

Right ok, it is called index.php. And right now I have this script running and I feel as though I'm almost there but I can't quite get it to work. I don't think it is picking the right ID to put into the url, so I'm still getting all of the threads under all categories.

 

index.php script:

<?php 

include "sqlconnect.php"; //mysql db connection here

print "<link rel='stylesheet' href='style.css' type='text/css'>";

print "<table class='maintable'>";

print "
<tr class='headline'>
<td width=50%>Genre</td>
<td width=20%>Description</td>
<td>Moderator ID</td>
</tr>
";

$getcat="select forum_genres.genre_id as id, genre_title, genre_desc, genre_mod
		from forum_genres
		left join forum_posts
		on forum_genres.genre_id = forum_posts.genre_id
		and forum_posts.postid = 0
		group by id;";

$getcat2=mysql_query($getcat) or die("Could not get categories");

if (mysql_num_rows($getcat2) == 0) {
echo " <br>\n";
echo " There are currently no categories in the forum.\n";
}
while($row=mysql_fetch_array($getcat2)) 

{

print "
<tr class='mainrow'>
<td><a href='viewThreads.php?id=$row[id]'>$row[genre_title]</a></td>
<td>$row[genre_desc]</td>
<td>$row[genre_mod]</td>
</tr>
";

}

print "</table>";

?>

 

Tom

 

ps, I really appreciate all the help your giving me.

Link to comment
Share on other sites

You might be one step ahead of yourself... It should go

 

Index

-->ViewForum

    -->ViewThread

 

Your index is going directly to viewing threads. Go to the main index for this forum. See any threads? Nope.. just categories. Click a category, and now you see threads. For what we are trying to accomplish, we shouldn't need any MySQL joins yet at all...

 

>ps, I really appreciate all the help your giving me.

 

yeah... they all say that! hehe

 

no problem man = ))

 

PhREEEk

Link to comment
Share on other sites

aha! ok ive got it to display the right threads under each category now. So now I need to get the new posts to display under the right category. Am I using a similar technique by passing the id through the url but using the $_POST function to submit the right catID into the database?

 

>ps, I really appreciate all the help your giving me.

 

yeah... they all say that! hehe

 

no problem man = ))

 

Hehe I feel humbled in your masterful presence!

 

Tom

Link to comment
Share on other sites

Ok im struggling a bit with passing a variable through a form so that it is submitted to the database.

 

Currently I have this script which should pass the variable $id to post.php:

 

<?php 

include "sqlconnect.php"; //mysql db connection here

$id=$_GET['id'];

print "<link rel='stylesheet' href='style.css' type='text/css'>";

print "<a href='post.php?id=$id'>New Topic</a><br>";

print "<table class='maintable'>";

print "<tr class='headline'><td width=50%>Topic</td><td width=20%>Topic Starter</td><td>Replies</td><td>Last replied time</td></tr>";



$getthreads="SELECT * from forum_posts where parentid='0' and genre_id='$id' order by lastrepliedto DESC";

$getthreads2=mysql_query($getthreads) or die("Could not get threads");

while($row=mysql_fetch_array($getthreads2))

{

  $getthreads3[title]=strip_tags($getthreads3[title]);

  $getthreads3[author]=strip_tags($getthreads3[author]);

  print "<tr class='mainrow'><td><a href='message.php?id=$row[postid]'>$row[title]</a></td><td>$row[author]</td><td>$row[numreplies]</td><td>$row[showtime]<br>Last post by <b>$row[lastposter]</b></td></tr>";

}

print "</table>";



?>  

 

And then I have the script on post.php which should pass $id into the database when submitted, but it doesnt:

 

<?php

include "sqlconnect.php"; //connection string

print "<link rel='stylesheet' href='style.css' type='text/css'>";

print "<table class='maintables'>";

print "<tr class='headline'><td>Post a message</td></tr>";

print "<tr class='maintables'><td>";

if(isset($_POST['submit']))

{

   $name=$_POST['name'];

   $yourpost=$_POST['yourpost'];

   $title=$_POST['title'];
   
   $id=$_POST['$id'];

   if(strlen($name)<1)

   {

      print "You did not type in a name."; //no name entered

   }

   else if(strlen($yourpost)<1)

   {

      print "You did not type in a post."; //no post entered

   }

   else if(strlen($title)<1)

   {

      print "You did not enter a title."; //no subject entered

   }

   else

   {

      $thedate=date("U"); //get unix timestamp

      $displaytime=date("F j, Y, g:i a");

      //we now strip HTML injections

      $subject=strip_tags($title);

      $name=strip_tags($name);

      $yourpost=strip_tags($yourpost); 

      $insertpost="INSERT INTO forum_posts(author,title,post,showtime,realtime,lastposter,genre_id) values('$name','$title','$yourpost','$displaytime','$thedate','$name', '$id')";

      mysql_query($insertpost) or die("Could not insert post"); //insert post

      print "Message posted, go back to <a href='index.php'>Forum</a>.";

   }



}

else

{

   $id=$_GET['id'];

   print "<form action='post.php' method='post'>";

   print "Your name:<br>";

   print "<input type='text' name='name' size='20'><br>";

   print "Title:<br>";

   print "<input type='text' name='title' size='20'><br>";

   print "Your message:<br>";

   print "<textarea name='yourpost' rows='5' cols='40'></textarea><br>";

   print "<input type='submit' name='submit' value='submit'></form>";



}

print "</td></tr></table>";

?>

 

Any help on this would be appreciated, thanks.

 

Tom

Link to comment
Share on other sites

At the top of each of your files, let's add the following:

 

<?php

// File: filename.php
//

.. rest of code here

 

That way it's easier to keep track of which file you're referring to when you post code. Let's also sync up with what you have so far... please post each individual file between BBCode code tags (add the above filename header). Also, post your MySQL database structure. If you don't know how to do that, just say so and I'll walk you through it.

 

Reason for all of this is, you're already a million miles into some really heavy coding errors which are going to cause almost total rewrites if we don't address them soon.

 

PS. Post your sqlconnect.php file as well... just xxxx out passwords and sensitive stuff.

 

PhREEEk

Link to comment
Share on other sites

Ok, here goes.

 

<?php 

// File: index.php
//

include "sqlconnect.php"; //mysql db connection here

print "<link rel='stylesheet' href='style.css' type='text/css'>";

print "<table class='maintable'>";

print "
<tr class='headline'>
<td width=50%>Screen Zero Film Forums</td>
<td width=20%><a href='unread.php'>Unread Posts</td>
</tr>
";

$getcat="select forum_genres.genre_id as id, genre_title, genre_desc, genre_mod
		from forum_genres
		left join forum_posts
		on forum_genres.genre_id = forum_posts.genre_id
		and forum_posts.postid = 0
		group by id;";

$getcat2=mysql_query($getcat) or die("Could not get categories");

if (mysql_num_rows($getcat2) == 0) {
echo " <br>\n";
echo " There are currently no categories in the forum.\n";
}

while($row=mysql_fetch_array($getcat2)) 

{

print "
<tr class='mainrow'>
<td><a href='viewThreads.php?id=$row[id]'>$row[genre_title]</a><br />$row[genre_desc]</td>
<td>$row[genre_mod]</td>
</tr>
";

}

print "</table>";

?>

 

<?php 

// File: viewThreads.php
//

include "sqlconnect.php"; //mysql db connection here

$id=$_GET['id'];

print "<link rel='stylesheet' href='style.css' type='text/css'>";

print "<a href='post.php?id=$id'>New Topic</a><br>";

print "<table class='maintable'>";

print "<tr class='headline'><td width=50%>Topic</td><td width=20%>Topic Starter</td><td>Replies</td><td>Last replied time</td></tr>";



$getthreads="select * from forum_posts where parentid='0' and genre_id='$id' order by lastrepliedto DESC";

$getthreads2=mysql_query($getthreads) or die("Could not get threads");

while($row=mysql_fetch_array($getthreads2))

{

  $getthreads3[title]=strip_tags($getthreads3[title]);

  $getthreads3[author]=strip_tags($getthreads3[author]);

  print "<tr class='mainrow'><td><a href='message.php?id=$row[postid]'>$row[title]</a></td><td>$row[author]</td><td>$row[numreplies]</td><td>$row[showtime]<br>Last post by <b>$row[lastposter]</b></td></tr>";

}

print "</table>";



?>  

 

<?php

// File: message.php
//

include "sqlconnect.php"; //mysql db connection here

$id=$_GET['id'];

print "<link rel='stylesheet' href='style.css' type='text/css'>";

print "<a href='index.php'>Back to main forum</a>-<A href='post.php'>New Topic</a>-<a href='reply.php?id=$id'>Reply<br>";

print "<table class='maintable'>";

print "<tr class='headline'><td width=20%>Author</td><td width=80%>Post</td></tr>";

$gettopic="SELECT * from forum_posts where postid='$id'";

$gettopic2=mysql_query($gettopic) or die("Could not get topic");

$gettopic3=mysql_fetch_array($gettopic2);

print "<tr class='mainrow'><td valign='top'>$gettopic3[author]</td><td valign='top'>Last replied to at $gettopic3[showtime]<br><hr>";

$message=strip_tags($gettopic3['post']);

$message=nl2br($message);

print "$message<hr><br>";

print "</td></tr>";

$getreplies="select * from forum_posts where parentid='$id' order by postid desc"; //getting replies

$getreplies2=mysql_query($getreplies) or die("Could not get replies");

while($getreplies3=mysql_fetch_array($getreplies2))

{

   print "<tr class='mainrow'><td valign='top'>$getreplies3[author]</td><td vakign='top'>Last replied to at $getreplies3[showtime]<br><hr>";

   $message=strip_tags($getreplies3['post']);

   $message=nl2br($message);

   print "$message<hr><br>";

   print "</td></tr>";

}

print "</table>";



?>  

 

<?php

// File: post.php
//

include "sqlconnect.php"; //connection string

print "<link rel='stylesheet' href='style.css' type='text/css'>";

print "<table class='maintables'>";

print "<tr class='headline'><td>Post a message</td></tr>";

print "<tr class='maintables'><td>";

if(isset($_POST['submit']))

{

   $name=$_POST['name'];

   $yourpost=$_POST['yourpost'];

   $title=$_POST['title'];
   
   $id=$_POST['id'];

   if(strlen($name)<1)

   {

      print "You did not type in a name."; //no name entered

   }

   else if(strlen($yourpost)<1)

   {

      print "You did not type in a post."; //no post entered

   }

   else if(strlen($title)<1)

   {

      print "You did not enter a title."; //no subject entered

   }

   else

   {

      $thedate=date("U"); //get unix timestamp

      $displaytime=date("F j, Y, g:i a");

      //we now strip HTML injections

      $subject=strip_tags($title);

      $name=strip_tags($name);

      $yourpost=strip_tags($yourpost); 

      $insertpost="INSERT INTO forum_posts(author,title,post,showtime,realtime,lastposter,genre_id) values('$name','$title','$yourpost','$displaytime','$thedate','$name','$id')";

      mysql_query($insertpost) or die("Could not insert post"); //insert post

      print "Message posted, go back to <a href='index.php'>Forum</a>.";

   }



}

else

{
   $id=$_GET['id'];

   print "<form action='post.php' method='post'>";
   
   print "<input type='hidden' name='id' value='$id'>";
   
   print "Your name:<br>";

   print "<input type='text' name='name' size='20'><br>";

   print "Title:<br>";

   print "<input type='text' name='title' size='20'><br>";

   print "Your message:<br>";

   print "<textarea name='yourpost' rows='5' cols='40'></textarea><br>";

   print "<input type='submit' name='submit' value='submit'></form>";



}

print "</td></tr></table>";

?>

 

<?php

// File: reply.php
//

include "sqlconnect.php"; //connection string

print "<link rel='stylesheet' href='style.css' type='text/css'>";

print "<table class='maintables'>";

print "<tr class='headline'><td>Reply</td></tr>";

print "<tr class='maintables'><td>";

if(isset($_POST['submit']))

{

   $name=$_POST['name'];

   $yourpost=$_POST['yourpost'];

   $subject=$_POST['subject'];

   $id=$_POST['id'];

   if(strlen($name)<1)

   {

      print "You did not type in a name."; //no name entered

   }

   else if(strlen($yourpost)<1)

   {

      print "You did not type in a post."; //no post entered

   }

   else

   {

      $thedate=date("U"); //get unix timestamp

      $displaytime=date("F j, Y, g:i a");

      //we now strip HTML injections

      $subject=strip_tags($subject);

      $name=strip_tags($name);

      $yourpost=strip_tags($yourpost); 

      $insertpost="INSERT INTO forum_posts(author,title,post,showtime,realtime,lastposter,parentid) values('$name','$subject','$yourpost','$displaytime','$thedate','$name','$id')";

      mysql_query($insertpost) or die("Could not insert post"); //insert post

      $updatepost="Update forum_posts set numreplies=numreplies+'1', lastposter='$name',showtime='$displaytime', lastrepliedto='$thedate' where postid='$id'";

      mysql_query($updatepost) or die("Could not update post");

      print "Message posted, go back to <A href='message.php?id=$id'>Message</a>.";

   }



}

else

{

   $id=$_GET['id'];

   print "<form action='reply.php' method='post'>";

   print "<input type='hidden' name='id' value='$id'>";

   print "Your name:<br>";

   print "<input type='text' name='name' size='20'><br>";

   print "Your message:<br>";

   print "<textarea name='yourpost' rows='5' cols='40'></textarea><br>";

   print "<input type='submit' name='submit' value='submit'></form>";



}

print "</td></tr></table>";

?>

 

<?php

//File sqlconnect.php
//

$sqlconnect = (mysql_connect("localhost", "root", "xxxxxxx") or die(mysql_error()));
mysql_select_db("forum_original") or die(mysql_error());
?>

 

--
-- Table structure for table `forum_genres`
--

CREATE TABLE `forum_genres` (
  `genre_id` int(20) NOT NULL auto_increment,
  `genre_title` varchar(100) collate latin1_general_ci NOT NULL default '',
  `genre_desc` varchar(255) collate latin1_general_ci NOT NULL default '',
  `genre_mod` int(5) NOT NULL default '0',
  PRIMARY KEY  (`genre_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=3 ;

-- --------------------------------------------------------

--
-- Table structure for table `forum_posts`
--

CREATE TABLE `forum_posts` (
  `postid` bigint(20) NOT NULL auto_increment,
  `author` varchar(255) collate latin1_general_ci NOT NULL default '',
  `title` varchar(255) collate latin1_general_ci NOT NULL default '',
  `post` mediumtext collate latin1_general_ci NOT NULL,
  `showtime` varchar(255) collate latin1_general_ci NOT NULL default '',
  `realtime` bigint(20) NOT NULL default '0',
  `lastposter` varchar(255) collate latin1_general_ci NOT NULL default '',
  `numreplies` bigint(20) NOT NULL default '0',
  `parentid` bigint(20) NOT NULL default '0',
  `lastrepliedto` bigint(20) NOT NULL default '0',
  `genre_id` int(20) NOT NULL default '1',
  PRIMARY KEY  (`postid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=19 ;

 

Ok there you go. That should be all of it. Not surprised I've made some coding errors. I did manage to solve the form post problem though, so that works now.

 

Tom

Link to comment
Share on other sites

-- Dumping data for table `forum_genres`
--

INSERT INTO `forum_genres` (`genre_id`, `genre_title`, `genre_desc`, `genre_mod`) VALUES
(1, 'Thrillers', 'Talk about Thrillers.', 1),
(2, 'Action', 'Talk about Action films', 2);

 

Its just dummy test data at the moment.

 

Tom

Link to comment
Share on other sites

ok, I'm all setup.. seeing exactly what you see now.

 

I need your .css file -

 

Now then, create a sub-folder in your docs called 'includes'

 

Dump this file into it. For right now, it just contains some debugging tools:

 

<?php
// File: functions.php
// Path: includes/

/* Function Library Coding Help */

function show_array($this_array, $desc = 'No Desc', $die = TRUE) {
echo "<br>//--> Array dump ($desc)";
echo "<br /><pre>";
print_r($this_array);
echo "</pre><br />";
if ( $die ) {
	die();
}

}

function show_session() {
echo "<br />//--> Session Vars for SID: " . session_id();
echo "<br /><pre>";
print_r($_SESSION);
echo "</pre><br />";

}

function show_input() {
if ( !empty($_POST) ) {
	echo "<br />//--> POST dump<br /><pre>";
	print_r($_POST);
	echo "</pre><br />";
} else {
	echo "<br />//--> No POST data available.<br />";
}
if ( !empty($_GET) ) {
	echo "<br />//--> GET dump<br /><pre>";
	print_r($_GET);
	echo "</pre><br />";
} else {
	echo "<br />//--> No GET data available.<br />";
}

}

?>

 

Next, change this at the top of index.php

 

<?php 

// File: index.php
//

include_once "sqlconnect.php"; //mysql db connection here
include_once "includes/functions.php";

 

PhREEEk

Link to comment
Share on other sites


//File: style.css
//

body {

a:link, a:visited, a:active { text-decoration: none}

font-family:Verdana, Sans-serif;

color; #000000;

font-size: 12px

}

input,textarea, select,{

color : #000000;

font: normal 12px;

border-collapse: collapse; border: 1px solid #000000;

}

.maintable {border: 0px ; width: 100%; padding: 0px; background-color: #FFFFFF}

.regrow {font-family: Verdana,Sans-serif; color: #000000; font-weight: bold; background-color: #FFFFFF;font-size: 12px;} 

.headline {font-family: Verdana,Sans-serif;font-weight: bold;color: #FFFFFF;background-color: #000000;font-size: 11px;} 

.forumrow {font-family: Verdana,Sans-serif; color: #000000;background-color: #F2F2F2;font-size: 12px;} 

.mainrow a:link, a:visited,  a:active { text-decoration: none;}

.mainrow {font-family: Verdana,Sans-serif; color: #000000;background-color: #999999;font-size: 12px; a:link, a:visited, a:active { text-decoration: none}}

.maintables{background-color: #FFFFFF; width: 95%; padding: 0px; border: 1px solid; cellspacing: no}

 

Ok ive got functions.php in now.

 

Tom

 

PS forgive my currently horrendous styling.

Link to comment
Share on other sites

Ok, here's some stuff...

 

First off, a new formatted css file:

 

body {
    font-family:Verdana, Sans-serif;
    color; #000000;
    font-size: 12px
}
a:link, a:visited, a:active {
    text-decoration: none
}
input,textarea, select {
    color : #000000;
    font: normal 12px;
    border-collapse: collapse;
    border: 1px solid #000000;
}
.maintable {
    border: 0px;
    width: 100%;
    padding: 0px;
    background-color: #FFFFFF
}
.regrow {
    font-family: Verdana,Sans-serif;
    color: #000000;
    font-weight: bold;
    background-color: #FFFFFF;
    font-size: 12px;
} 
.headline {
    font-family: Verdana,Sans-serif;
    font-weight: bold;
    color: #FFFFFF;
    background-color: #000000;
    font-size: 11px;
} 
.forumrow {
    font-family: Verdana,Sans-serif;
    color: #000000;
    background-color: #F2F2F2;
    font-size: 12px;
} 
.mainrow a:link, a:visited,  a:active {
    text-decoration: none;
}
.mainrow {
    font-family: Verdana,Sans-serif;
    color: #000000;
    background-color: #999999;
    font-size: 12px;
}
.maintables {
    background-color: #FFFFFF;
    width: 95%;
    padding: 0px;
    border: 1px solid;
}

 

Next, create a header and footer.php

 

<?php
// File: header.php
if ( !IN_FORUM ) {
    header("location: index.php");
}
if ( !$page_title ) {
    $page_title = 'Screen Zero Film Forums';
}
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>' . $page_title . '</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
';
?>

<?php
// File: footer.php
if ( !IN_FORUM ) {
    header("location: index.php");
}
echo '</body>
</html>
';
?>

 

Finally, a slightly revised index.php

<?php 

// File: index.php
//
define('IN_FORUM', true);
include_once "sqlconnect.php"; //mysql db connection here
include_once "includes/functions.php";

include "header.php";
print "<table class='maintable'>";

print "
<tr class='headline'>
<td width=50%>Screen Zero Film Forums</td>
<td width=20%><a href='unread.php'>Unread Posts</td>
</tr>
";

$getcat="select forum_genres.genre_id as id, genre_title, genre_desc, genre_mod
		from forum_genres
		left join forum_posts
		on forum_genres.genre_id = forum_posts.genre_id
		and forum_posts.postid = 0
		group by id;";

$getcat2=mysql_query($getcat) or die("Could not get categories");

if (mysql_num_rows($getcat2) == 0) {
echo " <br>\n";
echo " There are currently no categories in the forum.\n";
}

while($row=mysql_fetch_array($getcat2)) 

{

print "
<tr class='mainrow'>
<td><a href='viewThreads.php?id=$row[id]'>$row[genre_title]</a><br />$row[genre_desc]</td>
<td>$row[genre_mod]</td>
</tr>
";

}

print "</table>";
include "footer.php";

?>

 

Working on some other stuff...

 

PhREEEk

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.