Jump to content

[SOLVED] PHP echoes value three times...


trecool999

Recommended Posts

Every time I try to echo a value, it repeats it 3 times. Someone PLEASE HELP.

 

function ViewBoard() {
$BoardID = $_GET['Board'];

//Get Topics.
echo '<div class="tborder" style="margin-top: 1ex;">';
echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
echo '<tr>';
echo '<td class="catbg3">Subject</td>';
echo '<td class="catbg3">Started By</td>';
echo '<td class="catbg3">Replies</td>';
echo '<td class="catbg3">Views</td>';
echo '</tr>';
//Get and Write List.
$sql_topics = 'SELECT * FROM smf_messages, smf_topics WHERE smf_messages.ID_BOARD = ' . $BoardID . ' AND smf_topics.ID_BOARD = ' . $BoardID;
    $result_topics = mysql_query($sql_topics) or die('Topic collection error: ' . mysql_error());
while($topics = mysql_fetch_assoc($result_topics)) {
    echo '<tr>';
    echo '<td class="windowbg" valign="middle">';
	echo $topics['subject'];
	echo '</td>';
    echo '<td class="windowbg" valign="middle">';
	echo $topics['posterName'];
	echo '</td>';
    echo '<td class="windowbg" valign="middle">';
	echo $topics['numReplies'];
	echo '</td>';
	echo '<td class="windowbg" valign="middle">';
	echo $topics['numViews'];
	echo '</td>';
	echo '</tr>';
    }
echo '</table>';
echo '</div>';
}

Link to comment
https://forums.phpfreaks.com/topic/49501-solved-php-echoes-value-three-times/
Share on other sites

I think its you query...  try this:

 

SELECT * FROM smf_messages, smf_topics WHERE smf_messages.ID_BOARD = smf_topics.ID_BOARD AND smf_topics.ID_BOARD = ' . $BoardID;

 

You are never specifying how to join the tables so the query doesn't join them...  it looks for results in one table then pulls results for the next (I think).

I think its you query...  try this:

 

SELECT * FROM smf_messages, smf_topics WHERE smf_messages.ID_BOARD = smf_topics.ID_BOARD AND smf_topics.ID_BOARD = ' . $BoardID;

 

You are never specifying how to join the tables so the query doesn't join them...  it looks for results in one table then pulls results for the next (I think).

 

Nope, it still repeats the results three times...

Test (Locked)	trecool999	0	1
Test 2 (Locked)	trecool999	0	1
Test 3 (Locked)	trecool999	0	1
Topic (Locked)	trecool999	0	1
Test (Locked)	trecool999	0	0
Test 2 (Locked)	trecool999	0	0
Test 3 (Locked)	trecool999	0	0
Topic (Locked)	trecool999	0	0
Test (Locked)	trecool999	0	1
Test 2 (Locked)	trecool999	0	1
Test 3 (Locked)	trecool999	0	1
Topic (Locked)	trecool999	0	1
Test (Locked)	trecool999	0	0
Test 2 (Locked)	trecool999	0	0
Test 3 (Locked)	trecool999	0	0
Topic (Locked)	trecool999	0	0

Should Be:

Test (Locked)	trecool999	0	1
Test 2 (Locked)	trecool999	0	0
Test 3 (Locked)	trecool999	0	1
Topic (Locked)	trecool999	0	0

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.