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.

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());

I'm not as advanced. I don't know absolutely everything about PHP or SQL, so...yeah. :P

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"?

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.