contra10 Posted February 5, 2009 Share Posted February 5, 2009 how can i select more than one distinct i want the name variable and the id <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("userimages") or die(mysql_error()); $queryi = "SELECT DISTINCT(name) FROM `photoalbum` WHERE `userid` = '$id'"; $resulti = mysql_query($queryi); while($rowid = mysql_fetch_assoc($resulti)) { $ca= "{$rowid['name']}"; $iduu= "{$rowid['paid']}"; echo "<a href='http://localhost/photoalbum/albums.php?alb=$iduu'>$ca</a><br>"; } ?> Quote Link to comment Share on other sites More sharing options...
contra10 Posted February 5, 2009 Author Share Posted February 5, 2009 i tried something like this but it doesn't work $queryi = "SELECT DISTINCT(name, paid) FROM `photoalbum` WHERE `userid` = '$id'"; Quote Link to comment Share on other sites More sharing options...
skiingguru1611 Posted February 5, 2009 Share Posted February 5, 2009 Try $queryi = "SELECT DISTINCT name, paid FROM `photoalbum` WHERE `userid` = '$id'"; I've never used DISTINCT, but I think that should work. Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted February 5, 2009 Share Posted February 5, 2009 SELECT DISTINCT will only work with an individual field, use a GROUP BY claus Quote Link to comment 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.