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";
        $result=mysql_query($sql);


        echo ['playername'] ;
>close base

Thanks.

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

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

THANKS FOR HELPING,

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.

<?php

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";
$result=mysql_query($sql);

echo $ID ;

// close MySQL connection 
mysql_close();
?>

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.