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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.