Twister1004 Posted December 11, 2008 Share Posted December 11, 2008 Hi everyone. I'm just having a little bit of trouble, confusion, and.... you can guess. Objective: For this site, I'm trying to do this for a FBLA group at my school. (FBLA is a club) and I'm trying to make it like a "forum" in a way. This is just so they can post and reply to topics that are made. Problem: When I'm joining tables (I doubt I did them right) I'm echoing it out through an array. However it is posting it twice, rather than just once. What Can I do? community.php <body> <?php $jointable = mysql_query("SELECT post.topic_id, topic.topic_id, post.date, post.name, post.content, topic.topic_name FROM `post` INNER JOIN `topic` ON post.topic_id=topic.topic_id") or die("Error 70. Please contact Mrs.Dochety." . mysql_error()); //$thread = mysql_query("SELECT `topic_id`, `topic_name` FROM `topic` WHERE `topic_id` = '$topic'"); //$post = mysql_query("SELECT `topic_id`, `name`, `date`, `content` FROM `post` WHERE `topic_id` = '$thread'"); ?> <div class = "body"> <div class = "post"> <?php while($getinfo = mysql_fetch_array($jointable)){ echo $getinfo[3] . " Posted on " . $getinfo[2] . "<br/><br/>"; } ?> </div> </div> </body> index.php section <div id = "questions"> <center>Threads created</center><hr/> <?php $sqlthread = mysql_query("SELECT * FROM `topic` ORDER BY `topic_id` DESC LIMIT 7"); while($getthread = mysql_fetch_array($sqlthread)){ echo $getthread[3]; echo "<a href='./community.php?topicid=$getthread[0]&topic=$getthread[1]'>"; echo $getthread[1]; echo "</a>"; echo " - by " . $getthread[2]; echo "<br/>"; } ?> </div> view the site at: http://twistablepie.servegame.com/fbla/ any hints, tips, reading, posting, etc. is appreciated. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 11, 2008 Share Posted December 11, 2008 There is nothing in that code that indicates it would do it twice. Must be somewhere else in your code. Quote Link to comment Share on other sites More sharing options...
Twister1004 Posted December 11, 2008 Author Share Posted December 11, 2008 Thats what I said too. Could it be in the while code? I have no idea why it would be doing it twice. Unless I was echoing twice. Which I'm not. Any other ideas? Quote Link to comment Share on other sites More sharing options...
revraz Posted December 11, 2008 Share Posted December 11, 2008 Post the rest of the code. Quote Link to comment Share on other sites More sharing options...
Twister1004 Posted December 11, 2008 Author Share Posted December 11, 2008 I posted everything relivent to all the PHP stuff. Thats everything. The reast of the index is completely unnessarry. and thats all in the community.php. Quote Link to comment Share on other sites More sharing options...
Twister1004 Posted December 12, 2008 Author Share Posted December 12, 2008 I'm still stuck, but go figure . anyone have an idea? Quote Link to comment Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 I don't see what the problem is?? Quote Link to comment Share on other sites More sharing options...
Twister1004 Posted December 12, 2008 Author Share Posted December 12, 2008 If you go on the site, and click on one of the "Threads created" it will display the same thing for every one of them. Quote Link to comment Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 Your not using your post variables in the query, your just querying the whole database this $jointable = mysql_query("SELECT post.topic_id, topic.topic_id, post.date, post.name, post.content, topic.topic_name FROM `post` INNER JOIN `topic` ON post.topic_id=topic.topic_id") or die("Error 70. Please contact Mrs.Dochety." . mysql_error()); should be $topicid = (is_numeric($_POST['topicid']))? $_POST['topicid'] : 0; $jointable = mysql_query("SELECT post.topic_id, topic.topic_id, post.date, post.name, post.content, topic.topic_name FROM `post` INNER JOIN `topic` ON post.topic_id=topic.topic_id WHERE topic.topic_id='$topicid'") or die("Error 70. Please contact Mrs.Dochety." . mysql_error()); Quote Link to comment Share on other sites More sharing options...
Twister1004 Posted December 12, 2008 Author Share Posted December 12, 2008 I'm not as advanced. I don't know absolutely everything about PHP or SQL, so...yeah. Ok, just a question, if I may ask. What in the wold is this section supposed to do? ? $_POST['topicid'] : 0; what I dont get is the : 0; is that supposed to mean "Or 0"? Quote Link to comment Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 $topicid = (is_numeric($_POST['topicid']))? $_POST['topicid'] : 0; that is a short if statment, it says if $_POST['topicid'] is a number ass ign it to $topicid otherwise assign 0 (zero) to $topicid Quote Link to comment Share on other sites More sharing options...
Twister1004 Posted December 12, 2008 Author Share Posted December 12, 2008 Would it affect it if I changed it to $_REQUEST ? Thats the only way it seemed to work for me. By the way. Thanks everyone who tried to help me. =) Quote Link to comment Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 try changing it to $_GET apart from that is it working now? Quote Link to comment Share on other sites More sharing options...
Twister1004 Posted December 12, 2008 Author Share Posted December 12, 2008 I guess I should have shown that part where i made the $_GET part. I didn't think it was relivent. $topic = $_GET['topicid']; $name = $_GET['topic']; I changed it to $_REQUEST and it works just fine. Quote Link to comment Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 ahhh ok if it works happy days Quote Link to comment Share on other sites More sharing options...
Twister1004 Posted December 12, 2008 Author Share Posted December 12, 2008 Hehe. Thanks very much Gevans. =) 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.