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
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).

Link to comment
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).

 

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

Link to comment
Share on other sites

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

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.