Lonburak Posted February 10, 2011 Share Posted February 10, 2011 Guys, This is from a dating script which we created, we are trying to retrieve only FEMALE member pictures if the user is MALE and MALE pictures only if the user is FEMALE. Any ideas? I'd appreciate if you can please help us !! BELOW IS THE SCRIPT WE USE TO SHOW 10 PICTURES.. <? $get_pictures = mysql_query("SELECT * FROM user_pictures WHERE picture_type='1' AND picture_status='1' ORDER BY RAND() LIMIT 10"); $number = 0; while ($got_pictures = mysql_fetch_array($get_pictures)) { echo "<a href=\"member_profile.php?username=".$got_pictures['picture_username']."\" class=\"title_text\"> <img src=\"".$got_pictures['picture_path']."\" width=\"32\" height=\"44\" border=\"2\"></a> "; $number++; if ($number==5){ echo '</td></tr><tr><td>'; $number=0; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/227305-mysql-query-please-help/ Share on other sites More sharing options...
Maq Posted February 10, 2011 Share Posted February 10, 2011 (Please use tags next time) Quote Link to comment https://forums.phpfreaks.com/topic/227305-mysql-query-please-help/#findComment-1172480 Share on other sites More sharing options...
Maq Posted February 10, 2011 Share Posted February 10, 2011 Where do you store the user data whether they're female or male? Sessions? And what column from your table determines whether the picture is male or female? Quote Link to comment https://forums.phpfreaks.com/topic/227305-mysql-query-please-help/#findComment-1172483 Share on other sites More sharing options...
Lonburak Posted February 11, 2011 Author Share Posted February 11, 2011 Hi Maq, Sorry for improper using of forum The data for information regards to their gender is kept in a separate column and table; Table name: USER_INFO than follows as; ID USERNAME PASSWORD GENDER STARSIGN MARITALSTATUS EMAILADD LOCATION BASIC_PROFILE Thank you Quote Link to comment https://forums.phpfreaks.com/topic/227305-mysql-query-please-help/#findComment-1172528 Share on other sites More sharing options...
Jessica Posted February 11, 2011 Share Posted February 11, 2011 I assume user pictures has a user_id field somewhere? You'll have to join the tables. Also, slightly off topic, but if you're going to allow users to join regardless of martial status, you might as well allow gay and bi users. In fact, I'd choose that OVER a site that encourages cheating. Quote Link to comment https://forums.phpfreaks.com/topic/227305-mysql-query-please-help/#findComment-1172529 Share on other sites More sharing options...
Lonburak Posted February 11, 2011 Author Share Posted February 11, 2011 What i done now is under USER_PICTURES i created new column USER_GENDER_PIC SELECT * FROM user_pictures WHERE picture_type='1' AND user_gender_pic='male' AND picture_status='1' ORDER BY RAND() LIMIT 10 I've being able to filter the pictures whether if they are MALE or FEMALE - but - how can i make MALES visible to FEMALES and FEMALES visible to MALES only..? Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/227305-mysql-query-please-help/#findComment-1172535 Share on other sites More sharing options...
Lonburak Posted February 11, 2011 Author Share Posted February 11, 2011 Jesirose, To be honest with you its a MATRIMONIAL website for a client lives in Turkey ) They wont be interested with GAY and BI marriage (as per instructed) ) Quote Link to comment https://forums.phpfreaks.com/topic/227305-mysql-query-please-help/#findComment-1172536 Share on other sites More sharing options...
Jessica Posted February 11, 2011 Share Posted February 11, 2011 What i done now is under USER_PICTURES i created new column USER_GENDER_PIC SELECT * FROM user_pictures WHERE picture_type='1' AND user_gender_pic='male' AND picture_status='1' ORDER BY RAND() LIMIT 10 I've being able to filter the pictures whether if they are MALE or FEMALE - but - how can i make MALES visible to FEMALES and FEMALES visible to MALES only..? Thank you! Use an if/else. Quote Link to comment https://forums.phpfreaks.com/topic/227305-mysql-query-please-help/#findComment-1172537 Share on other sites More sharing options...
Lonburak Posted February 11, 2011 Author Share Posted February 11, 2011 Argh Dnt work! Quote Link to comment https://forums.phpfreaks.com/topic/227305-mysql-query-please-help/#findComment-1172538 Share on other sites More sharing options...
mikosiko Posted February 11, 2011 Share Posted February 11, 2011 Hmmm... if you have the USER GENDER available before show him/her pictures is not as simple as do this: SELECT * FROM user_pictures WHERE picture_type='1' AND user_gender_pic != $UserGender AND picture_status='1' ORDER BY RAND() LIMIT 10 been $UserGender ... well... is obvious what should be right? Quote Link to comment https://forums.phpfreaks.com/topic/227305-mysql-query-please-help/#findComment-1172546 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.