NathanLedet Posted July 14, 2008 Share Posted July 14, 2008 this just crept up on me and I'm completely puzzled as to why it's happening. Login page logs you in, and then on to the Admin features: <?php session_start(); include('includes/mysql_connect.php'); $query2 = 'SELECT userID FROM users WHERE username = "' . $_SESSION['MM_Username'] . '"'; $result2 = mysql_query($query2); while($row2 = mysql_fetch_array($result2, MYSQL_ASSOC)){ $userID = $row2['userID']; } $query = "SELECT users.userID, users.username, addressbook.userID, addressbook.name, addressbook.email, addressbook.emailID"; $query .= " FROM users, addressbook"; $query .= " WHERE addressbook.userID = \"" . $userID . "\""; $query .= " ORDER BY addressbook.name ASC"; $result = mysql_query($query); echo "<table width=\"500px\" border=\"0\">\r <tr>\r <td width=\"25%\">Name</td>\r <td width=\"60%\">E-mail Address</td>\r <td width=\"15%\">Options</td>\r </tr>\r </table>"; echo "<div style=\"width:500px; height:225px; overflow:auto;\">"; echo "<table width=\"500px\" border=\"0\" id=\"addressbook\">\r"; while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ echo "<tr> <td width=\"25%\" class=\"tbldata\">{$row['name']}</td> <td width=\"60%\" class=\"tbldata\">{$row['email']}</td> <td width=\"15%\" class=\"tbldata\"><a href=\"/addressbook_update.php?emailID={$row['emailID']}\">Edit</a> / <a href=\"/addressbook_delete.php?emailID={$row['emailID']}\">Delete</a></td> </tr>\r"; } echo "</table>\r</div>"; ?> It works (it's also a sloppy way of doing it, I realize this, but I'm a newbie just trying to get it to work first ), but the results of the query displays each item twice. Quote Link to comment https://forums.phpfreaks.com/topic/114612-query-results-are-2-of-each/ Share on other sites More sharing options...
cooldude832 Posted July 14, 2008 Share Posted July 14, 2008 what is you question??? Quote Link to comment https://forums.phpfreaks.com/topic/114612-query-results-are-2-of-each/#findComment-589270 Share on other sites More sharing options...
NathanLedet Posted July 14, 2008 Author Share Posted July 14, 2008 I am getting the results displayed twice. so if I have 1 entry in the database, it shows up twice, and it's not supposed to. It's only supposed to show up once. Is it possible that it has something to do with the session that is stored upon login? Quote Link to comment https://forums.phpfreaks.com/topic/114612-query-results-are-2-of-each/#findComment-589282 Share on other sites More sharing options...
.josh Posted July 14, 2008 Share Posted July 14, 2008 I think the problem is with your query string. You're selecting data from two different tables but your where clause only restricts one of them. I think you're going to need to add a JOIN in there somewhere. I think. I'm really not that great at query strings. But I'm pretty sure it's your actual query string. I can move this over to the sql forum if you want... Quote Link to comment https://forums.phpfreaks.com/topic/114612-query-results-are-2-of-each/#findComment-589289 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.