trecool999 Posted May 1, 2007 Share Posted May 1, 2007 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>'; } Quote Link to comment https://forums.phpfreaks.com/topic/49501-solved-php-echoes-value-three-times/ Share on other sites More sharing options...
jworisek Posted May 1, 2007 Share Posted May 1, 2007 what is being echoed 3 times? are you pulling 3 results from your query? Quote Link to comment https://forums.phpfreaks.com/topic/49501-solved-php-echoes-value-three-times/#findComment-242638 Share on other sites More sharing options...
trecool999 Posted May 1, 2007 Author Share Posted May 1, 2007 Ok: The results are in the Database (MySQL), but when I get them and use 'mysql_fetch_assoc' and echo it once, it repeats it 3 times. Example: http://trecool999.prophp.org/Forum/psp_index.php?Board=2 Quote Link to comment https://forums.phpfreaks.com/topic/49501-solved-php-echoes-value-three-times/#findComment-242668 Share on other sites More sharing options...
jworisek Posted May 1, 2007 Share Posted May 1, 2007 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). Quote Link to comment https://forums.phpfreaks.com/topic/49501-solved-php-echoes-value-three-times/#findComment-242692 Share on other sites More sharing options...
trecool999 Posted May 1, 2007 Author Share Posted May 1, 2007 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... Quote Link to comment https://forums.phpfreaks.com/topic/49501-solved-php-echoes-value-three-times/#findComment-242700 Share on other sites More sharing options...
trecool999 Posted May 1, 2007 Author Share Posted May 1, 2007 Hmm... It seems that it times' the results by the number of topics on there... Quote Link to comment https://forums.phpfreaks.com/topic/49501-solved-php-echoes-value-three-times/#findComment-242759 Share on other sites More sharing options...
jworisek Posted May 1, 2007 Share Posted May 1, 2007 well its really hard to know what you are expecting.... post the rows of data that you should be getting... you weren't getting 3 repeated rows of the same data to begin with. Quote Link to comment https://forums.phpfreaks.com/topic/49501-solved-php-echoes-value-three-times/#findComment-242825 Share on other sites More sharing options...
fenway Posted May 1, 2007 Share Posted May 1, 2007 Well, with "*", "half" of the data will necessarily be repeated, since you'll get all the tables munged togethers. Quote Link to comment https://forums.phpfreaks.com/topic/49501-solved-php-echoes-value-three-times/#findComment-242877 Share on other sites More sharing options...
trecool999 Posted May 1, 2007 Author Share Posted May 1, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/49501-solved-php-echoes-value-three-times/#findComment-242921 Share on other sites More sharing options...
trecool999 Posted May 1, 2007 Author Share Posted May 1, 2007 Ok, I fixed it . Thanks for help anyway . Quote Link to comment https://forums.phpfreaks.com/topic/49501-solved-php-echoes-value-three-times/#findComment-242992 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.