Jump to content

twsowerby

Members
  • Posts

    79
  • Joined

  • Last visited

    Never

Everything posted by twsowerby

  1. 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, simple is good =) Tom
  2. 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>"; ?>
  3. 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
  4. 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
×
×
  • 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.