Jump to content

Mysql Query! Please help..


Lonburak

Recommended Posts

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;
	  }
	  }
	  ?>

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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. ;)

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.