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? Link to comment https://forums.phpfreaks.com/topic/28646-showing-information-from-certain-table-row/ 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. Link to comment https://forums.phpfreaks.com/topic/28646-showing-information-from-certain-table-row/#findComment-131064 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? Link to comment https://forums.phpfreaks.com/topic/28646-showing-information-from-certain-table-row/#findComment-131065 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 Link to comment https://forums.phpfreaks.com/topic/28646-showing-information-from-certain-table-row/#findComment-131067 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] Link to comment https://forums.phpfreaks.com/topic/28646-showing-information-from-certain-table-row/#findComment-131079 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 Link to comment https://forums.phpfreaks.com/topic/28646-showing-information-from-certain-table-row/#findComment-131082 Share on other sites More sharing options...
Unholy Prayer Posted November 27, 2006 Author Share Posted November 27, 2006 Thanks! That helped a bunch! Link to comment https://forums.phpfreaks.com/topic/28646-showing-information-from-certain-table-row/#findComment-131087 Share on other sites More sharing options...
piznac Posted November 27, 2006 Share Posted November 27, 2006 np Link to comment https://forums.phpfreaks.com/topic/28646-showing-information-from-certain-table-row/#findComment-131089 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.