Posted By

sriganesh on 07/03/11


Tagged

random


Versions (?)

[Gravity Forms]Random form value


 / Published in: PHP
 

URL: http://www.gravityhelp.com/forums/topic/random-form-value

  1. <?php
  2.  
  3. function get_random_field_value($form_id, $field_number){
  4. global $wpdb;
  5.  
  6. $table = RGFormsModel::get_lead_details_table_name();
  7.  
  8. return $wpdb->get_var($wpdb->prepare("SELECT value FROM $table WHERE form_id = %d AND field_number = %d ORDER BY rand() LIMIT 1", $form_id, $field_number));
  9. }
  10.  
  11. echo get_random_field_value(40, 3);

Report this snippet  

You need to login to post a comment.