Jump to content

how to run a random sql that look for one peremeter?


loshyt

Recommended Posts

here is the database:

uwzlyh0ygjvo.jpg

its a facebook app

 

i want that my sql will choose every time random but considerate in the sex parameter.

i mean that if the user is boy i will put it in parameter and boys is num-1 girls-0

and if the user is boy it will run random sql just on the boys

and if its girls so random on the girls

 

 

here what i did:

$sql = "SELECT * FROM  pcm ORDER BY RAND() LIMIT 1";
  $Recordset3 = mysql_query($sql) or die(mysql_error());
  $row2 = mysql_fetch_object($Recordset3);
  print_r($row2);

 

 

but for some reason i get an error that the database is not selected

 

maybe i didnt select my database right?

 

plz help tnx....

Link to comment
Share on other sites

but for some reason i get an error that the database is not selected

 

maybe i didnt select my database right?

 

please help tnx....

 

okay prev post was the query...that error sounds like you aren't selecting a db when you make a connection...in your code, somewhere before the query, after you use mysql_connect() to connect to connect to mysql, you should be using mysql_select_db to select which db your table is in

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.