从MySQL提取随机值到wordpress

How do I extract random values ​​from MySQL on wordpress?

I want to create a button with script generates, clicking will have to exit the extracted value from mysql, any value can be extracted only 3 times?

Database name codefriend and into database there are more value example= 123, 222, 333, 1231, 3212

Since you did not specify any table, here is an idea:

$arr_values = array();
$arr_tables = get all tableNames in codefriend-DB. mysql has function to do that.
for ($i = 0; $i < count($arr_tables); $i++) {
    // for each table, get field name list
    $arr_fields = get fields name from mysql
    $total_records = get total record for this table from mysql

    $random_fields = rand(0, count(arr_fields)-1); // get random number between 0 and last index of fields array
    $random_id = rand(1, total_records);

    // get the value from sql query
    $query = "SELECT ".$arr_fields[$random_fields]." FROM ".$arr_tables[i]." WHERE id =".$random_id;
    $string = mysql_result($query);   // get the value to array

    $total_extractions = array_count_values($arr_values);// this will list all occurance for each value
    if($total_extractions[$string] < 3 )
    {
       // append the value
       $arr_values[] = $string;
    }
} 

This is just sudo code, I did not test it.