loony383 Posted August 8, 2007 Share Posted August 8, 2007 Hi im trying to make it so veiw_forum.php?forumid=1 displays all the information from the database that has forumid to the value passed in the varible, but my code isnt working <html> <head> <title>Airboard - Beta</title> <?php include ("menu.php"); include "connect.php"; //mysql db connection here $forumid = $_GET['forumid']; print "<link rel='stylesheet' href='style.css' type='text/css'>"; print "<A href='post.php?forumid=$forumid'>New Topic</a>"; 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 forumtutorial_posts where parentid='0' and forumid='$forumid' order by realtime DESC"; $getthreads2=mysql_query($getthreads) or die("Could not get threads"); while($getthreads3=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=$getthreads3[postid]'>$getthreads3[title]</td><td>$getthreads3[author]</td><td>$getthreads3[numreplies]</td><td>$getthreads3[showtime] Last post by $getthreads3[lastposter]</td></tr>"; } print "</table>"; ?> instead its showing all the posts not just ones with forumid to 1. Also my 2nd problem is when my post.php?forumid=1 inserts information of the topic to the database it isnt inserting forumid to 1 its leaving it blank, heres my code <?php include("include/session.php"); include "header.php"; include ("menu.php"); function checkLogin() { global $database; if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookid'])) { $this->username = $_SESSION['username'] = $_COOKIE['cookname']; $this->userid = $_SESSION['userid'] = $_COOKIE['cookid']; } } if ($session->username == 'Guest') { echo "You need to login to create a topic"; exit(); } 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=$session->username; $yourpost=$_POST['yourpost']; $forumid = $_GET['forumid']; $subject=$_POST['subject']; if(strlen($yourpost)<1) { print "You did not type in a post."; //no post entered } else if(strlen($subject)<1) { print "You did not enter a subject."; //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($subject); $name=strip_tags($name); $yourpost=strip_tags($yourpost); $insertpost="INSERT INTO forumtutorial_posts(author,title,post,showtime,realtime,lastposter,forumid) values('$name','$subject','$yourpost','$displaytime','$thedate','$name','$forumid')"; mysql_query($insertpost) or die("Could not insert post"); //insert post print "Message posted, go back to <A href='index.php?forumid=$forumid'>Forum</a>."; } } else { print "<form action='post.php' method='post'>"; print "Subject:<br>"; print "<input type='text' name='subject' 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>"; include "footer.php"; ?> Quote Link to comment Share on other sites More sharing options...
trq Posted August 8, 2007 Share Posted August 8, 2007 You never define the $forumid used in your query. Should be.... $getthreads="SELECT * from forumtutorial_posts where parentid='0' and forumid='{$_GET['forumid']}' order by realtime DESC"; Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted August 8, 2007 Share Posted August 8, 2007 Thorpe: The id is defined with this line: $forumid = $_GET['forumid']; loony383 : However, in your second script, you don't appear to define $forumid anywhere. Quote Link to comment Share on other sites More sharing options...
trq Posted August 8, 2007 Share Posted August 8, 2007 Hehe... I must be going blind. Quote Link to comment Share on other sites More sharing options...
loony383 Posted August 8, 2007 Author Share Posted August 8, 2007 It is defined in the seccond script with $forumid = $_GET['forumid']; after you scroll down a bit, thanks for the help but still nothing is working Quote Link to comment Share on other sites More sharing options...
loony383 Posted August 8, 2007 Author Share Posted August 8, 2007 *bump* 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.