Jump to content

[SOLVED] I'm having a little bit of issues. I honestly don't know what I can do.


Twister1004

Recommended Posts

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>

tablemz5.png

 

view the site at: http://twistablepie.servegame.com/fbla/

 

any hints, tips, reading, posting, etc. is appreciated.

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.