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. Link to comment https://forums.phpfreaks.com/topic/136499-solved-im-having-a-little-bit-of-issues-i-honestly-dont-know-what-i-can-do/ 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. Link to comment https://forums.phpfreaks.com/topic/136499-solved-im-having-a-little-bit-of-issues-i-honestly-dont-know-what-i-can-do/#findComment-712484 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? Link to comment https://forums.phpfreaks.com/topic/136499-solved-im-having-a-little-bit-of-issues-i-honestly-dont-know-what-i-can-do/#findComment-712493 Share on other sites More sharing options...
revraz Posted December 11, 2008 Share Posted December 11, 2008 Post the rest of the code. Link to comment https://forums.phpfreaks.com/topic/136499-solved-im-having-a-little-bit-of-issues-i-honestly-dont-know-what-i-can-do/#findComment-712508 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. Link to comment https://forums.phpfreaks.com/topic/136499-solved-im-having-a-little-bit-of-issues-i-honestly-dont-know-what-i-can-do/#findComment-712894 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? Link to comment https://forums.phpfreaks.com/topic/136499-solved-im-having-a-little-bit-of-issues-i-honestly-dont-know-what-i-can-do/#findComment-713212 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?? Link to comment https://forums.phpfreaks.com/topic/136499-solved-im-having-a-little-bit-of-issues-i-honestly-dont-know-what-i-can-do/#findComment-713214 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. Link to comment https://forums.phpfreaks.com/topic/136499-solved-im-having-a-little-bit-of-issues-i-honestly-dont-know-what-i-can-do/#findComment-713225 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()); Link to comment https://forums.phpfreaks.com/topic/136499-solved-im-having-a-little-bit-of-issues-i-honestly-dont-know-what-i-can-do/#findComment-713230 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"? Link to comment https://forums.phpfreaks.com/topic/136499-solved-im-having-a-little-bit-of-issues-i-honestly-dont-know-what-i-can-do/#findComment-713245 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 Link to comment https://forums.phpfreaks.com/topic/136499-solved-im-having-a-little-bit-of-issues-i-honestly-dont-know-what-i-can-do/#findComment-713248 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. =) Link to comment https://forums.phpfreaks.com/topic/136499-solved-im-having-a-little-bit-of-issues-i-honestly-dont-know-what-i-can-do/#findComment-713253 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? Link to comment https://forums.phpfreaks.com/topic/136499-solved-im-having-a-little-bit-of-issues-i-honestly-dont-know-what-i-can-do/#findComment-713256 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. Link to comment https://forums.phpfreaks.com/topic/136499-solved-im-having-a-little-bit-of-issues-i-honestly-dont-know-what-i-can-do/#findComment-713258 Share on other sites More sharing options...
gevans Posted December 12, 2008 Share Posted December 12, 2008 ahhh ok if it works happy days Link to comment https://forums.phpfreaks.com/topic/136499-solved-im-having-a-little-bit-of-issues-i-honestly-dont-know-what-i-can-do/#findComment-713261 Share on other sites More sharing options...
Twister1004 Posted December 12, 2008 Author Share Posted December 12, 2008 Hehe. Thanks very much Gevans. =) Link to comment https://forums.phpfreaks.com/topic/136499-solved-im-having-a-little-bit-of-issues-i-honestly-dont-know-what-i-can-do/#findComment-713266 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.