Forum Replies Created

Viewing 1 replies (of 1 total)
  • You can try not to rely on the SQL RAND function. It is probably causing the runtime error of not displaying random quotes. This could be an idea:

    $sql = "SELECT COUNT(quotes_id) FROM " . $this->table_name;
    $record_count = $wpdb->get_var( $sql );	
    
    $random_id = mt_rand(1, $record_count);
    		
    $sql = "SELECT quote, first_name, last_name, source, img_url FROM " . $this->table_name . " WHERE quotes_id = " . $random_id;
    
    $quote_data = $wpdb->get_row( $sql, ARRAY_A );

    [Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]

    • This reply was modified 8 years, 11 months ago by rehernandez.
    • This reply was modified 8 years, 11 months ago by bdbrown.
    • This reply was modified 8 years, 11 months ago by bdbrown.
Viewing 1 replies (of 1 total)