ccrevcypsys Posted November 2, 2007 Share Posted November 2, 2007 I have a website that has users and artists on it. I am building the community page ( the page that displays everyone in the db) well i figured out the view all artists and all people but i need help figuring out how to just view the customers without the artists on the page. My db is set up like this --|customers|-- --|artists|-- screenname +---customer_id email points password customer_id ---+ and my code for the query is this so far $query = "SELECT * FROM ".$glob['dbprefix']."customer LEFT JOIN ".$glob['dbprefix']."artist ON ".$glob['dbprefix']."StreamRush_customer.customer_id=".$glob['dbprefix']."artist.customer_id WHERE private = 0 ORDER BY noOrders"; Quote Link to comment https://forums.phpfreaks.com/topic/75848-selecting-problems/ Share on other sites More sharing options...
otuatail Posted November 2, 2007 Share Posted November 2, 2007 Can't work out your DB is this one table of both or 2 seperate tables? could you itemise them downward for each? Desmond. Quote Link to comment https://forums.phpfreaks.com/topic/75848-selecting-problems/#findComment-383874 Share on other sites More sharing options...
ccrevcypsys Posted November 2, 2007 Author Share Posted November 2, 2007 Can't work out your DB is this one table of both or 2 seperate tables? could you itemise them downward for each? Desmond. its 2 different tables customer is its own table and artist is its own table and the customer table has everyone registered on the site but the artist table says who is the artists. Quote Link to comment https://forums.phpfreaks.com/topic/75848-selecting-problems/#findComment-383876 Share on other sites More sharing options...
ccrevcypsys Posted November 2, 2007 Author Share Posted November 2, 2007 I have also tried this $query = "SELECT * FROM ".$glob['dbprefix']."StreamRush_customer LEFT JOIN ".$glob['dbprefix']."artist ON ".$glob['dbprefix']."StreamRush_customer.customer_id=".$glob['dbprefix']."artist.customer_id WHERE ".$glob['dbprefix']."StreamRush_customer.customer_id!=".$glob['dbprefix']."artist.customer_id AND private = 0 ORDER BY noOrders"; and it causes the table not to generate Quote Link to comment https://forums.phpfreaks.com/topic/75848-selecting-problems/#findComment-383878 Share on other sites More sharing options...
kratsg Posted November 3, 2007 Share Posted November 3, 2007 Try something like this :-o $artists = mysql_query("SELECT customer_id FROM artists"); $artist = mysql_fetch_array($artists); //$artists is now an array of ALL customer ids that are artists :-o mysql_clear_result($artists);//clear off the memory so you can perform another query efficiently $customers = mysql_query("SELECT screenname,email,customer_id FROM customers"); while($row = mysql_fetch_array($customers)){//loop through all your registered users if(!in_array($row['customer_id'],$artists)){//they are not an artist //do some html to display customer data } } mysql_clear_result($customers);//clear off the memory so you have efficiency :-D Let me know if this code makes sense or not. I'd rather use codes like this than mess with LEFT JOIN, RIGHT JOIN, etc... where I can. Quote Link to comment https://forums.phpfreaks.com/topic/75848-selecting-problems/#findComment-383978 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.