Unholy Prayer Posted November 27, 2006 Share Posted November 27, 2006 Ok, I'm trying to make a forum for my website. I have my idex page pretty much done, but how do I make the viewforum.php page so it shows threads from the forum that they clicked on? Quote Link to comment Share on other sites More sharing options...
piznac Posted November 27, 2006 Share Posted November 27, 2006 Try using a URL variable that coresponds with a primary key in your database. Likeviewforum.php?num=29 where 29 is the number of the thread in which they clicked. TYhen you can pull the query based on that number. Quote Link to comment Share on other sites More sharing options...
Unholy Prayer Posted November 27, 2006 Author Share Posted November 27, 2006 How do I make it so it displays it by the number in the url? Quote Link to comment Share on other sites More sharing options...
piznac Posted November 27, 2006 Share Posted November 27, 2006 well,.. if you can get the number in the URL to begin with you could use something like this:[quote]$num = $_GET['num'];$sql = "SELECT yourtable WHERE num = $num"[/quote]or something like that Quote Link to comment Share on other sites More sharing options...
Unholy Prayer Posted November 27, 2006 Author Share Posted November 27, 2006 Ok, so far so good... not getting any error messages when I click on the link to the forum from the index, but there aren't any threads in it yet. How do I display a message saying that there aren't any? Here is my code:[code]<?phpinclude('styles/default/page_header.tpl');require_once('config.php');$fid = $_GET['id'];echo "<table align='center' width='95%' cellspacing='1' cellpadding='1' border='0' class='table'> <tr> <td colspan='4' class='bgcat>Viewing Threads in: $forumname</td> </tr><tr> <td align='left' width='50%' class='cellnames'>Thread Subject</td> <td align='left' width='20%' class='cellnames'>Thread Starter</td> <td align='left' width='10%' class='cellnames'>Replies</td> <td align='left' width='20%' class='cellnames'>Last Updated</td> </tr><tr>";$threads = mysql_query("select * from threads where fid = $fid order by id");while($t=mysql_fetch_array($threads)) { $id=$t["id"]; $author=$t["author"]; $subject=$t["subject"]; $message=$t["message"]; $date=$t["date"]; $time=$t["time"]; echo "<td align='left' width='50%' class='forumrow'><a href='viewthread.php?id=$id'>$subject</a></td> <td align='left' width='20%' class='forumrow'>$author</td> <td align='left' width='10%' class='forumrow'>0</td> <td align='left' width='20%' class='forumrow'>On $date at $time</td> </tr><tr>"; }?>[/code] Quote Link to comment Share on other sites More sharing options...
piznac Posted November 27, 2006 Share Posted November 27, 2006 not sure if this is the best way but you could do this[quote]<?phpinclude('styles/default/page_header.tpl');require_once('config.php');$fid = $_GET['id'];echo "<table align='center' width='95%' cellspacing='1' cellpadding='1' border='0' class='table'> <tr> <td colspan='4' class='bgcat>Viewing Threads in: $forumname</td> </tr><tr> <td align='left' width='50%' class='cellnames'>Thread Subject</td> <td align='left' width='20%' class='cellnames'>Thread Starter</td> <td align='left' width='10%' class='cellnames'>Replies</td> <td align='left' width='20%' class='cellnames'>Last Updated</td> </tr><tr>";$threads = mysql_query("select * from threads where fid = $fid order by id");if($threads == " "){echo "No threads to display";}while($t=mysql_fetch_array($threads)) { $id=$t["id"]; $author=$t["author"]; $subject=$t["subject"]; $message=$t["message"]; $date=$t["date"]; $time=$t["time"]; echo "<td align='left' width='50%' class='forumrow'><a href='viewthread.php?id=$id'>$subject</a></td> <td align='left' width='20%' class='forumrow'>$author</td> <td align='left' width='10%' class='forumrow'>0</td> <td align='left' width='20%' class='forumrow'>On $date at $time</td> </tr><tr>"; }?>[/quote]Like I said there is probably a better way,.. but that should work Quote Link to comment Share on other sites More sharing options...
Unholy Prayer Posted November 27, 2006 Author Share Posted November 27, 2006 Thanks! That helped a bunch! Quote Link to comment Share on other sites More sharing options...
piznac Posted November 27, 2006 Share Posted November 27, 2006 np Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.