doomdude Posted September 25, 2011 Share Posted September 25, 2011 Hey guys, not sure what's gone wrong here, but this displays the select query twice on my page. <?php $result = mysql_query("SELECT * FROM members WHERE Username='$_SESSION[username]'") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo '<b>Resources</b><br />'; echo 'Wood: ' . $row['res1'] . ' <br />'; echo 'Iron: ' . $row['res2'] . ' <br />'; } ?> Displays as: Resources Wood: 2000 Iron: 1000 Resources Wood: 0 Iron: 0 The first set of numbers are correct, but I'm not sure where the second lot are been called from? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/247828-duplicate-display-from-select/ Share on other sites More sharing options...
RobertP Posted September 25, 2011 Share Posted September 25, 2011 check your database, my only explanation would be you have to rows in your table with the same username. maybe consider setting the username to primary Quote Link to comment https://forums.phpfreaks.com/topic/247828-duplicate-display-from-select/#findComment-1272570 Share on other sites More sharing options...
doomdude Posted September 25, 2011 Author Share Posted September 25, 2011 Ah my bad, I've got two account's with the same user name, Now I've got to figure out how to stop multiple usernames been the same :/ Quote Link to comment https://forums.phpfreaks.com/topic/247828-duplicate-display-from-select/#findComment-1272574 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.