I am trying to write a querry to pull just one playername out of a database by random,

can anyone see what I am missing please ?

open base<
    $sql="select playername from tablejollys
          where (ID % 1000) = floor(rand() * 1000)
          order by rand()
          limit 1";

        echo ['playername'] ;
>close base


I think you do not need where condition, following should work

$sql="select playername from tablejollys  order by rand()  limit 1";


I am just geting a blank white page with nothing now, ,
have looked into the base and have 2 records in there.
this is where i am up to just a now.


header('Access-Control-Allow-Origin: *');
$host="myhost"; // Host name 
$username="mybasename"; // Mysql username 
$password="password987"; // Mysql password 
$db_name="mybase"; // Database name 
$tbl_name="jollys"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// Retrieve data from database 
$sql="select ID from jollys  order by rand()  limit 1";

echo $ID ;

// close MySQL connection 

The reason this line,

where (ID % 1000) = floor(rand() * 1000)

,was added at first was because i read sumwhere it would slow down when there were lots of records to play with ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.