Join a select form with the number of the database to check I have this select form:

$options = array(
      'twenty' =&gt; '20',
      'hundred' =&gt; '100',
      'five_hundred' =&gt; '500',
      'thousand' =&gt; '1.000',
      'five_thousand' =&gt; '5.000',
      'ten_thousand' =&gt; '10.000',
      'hudred_thousand' =&gt; '100.000',
      'million' =&gt; '1.000.000',
      'two-million' =&gt; '2.000.000',
  );

  $form['number_select'] = array(
    '#type' =&gt; 'select',
    '#options' =&gt; $options,
    '#description' =&gt; t('Select the number of values that you want to check.'),
  );


I want according to what number the user has selected to limit the same number how i can solve this problem?

my DB code is this:

function something_cron()

  $number = variable_get(number_select)
  $query = db_select('watchdog', 'wa')
    -&gt;orderBy('wid')
    -&gt;fields('wa', array('variables', 'type', 'severity', 'message', 'wid',
    'timestamp'))
    -&gt;condition('wid', $last_id, '&gt;')
    -&gt;range(0,$number);
  $result = $query-&gt;execute();

  // Loop through each item and add to $row.
  foreach ($result as $row) {
    someother();
  }
Change your options to this:

$options = array(
      '20' =&gt; '20',
      '100' =&gt; '100',
      '500' =&gt; '500',
      '1000' =&gt; '1.000',
...
  );


Then you can use the value directly. It'll be a number. Also you need a #default_value:

#default_value =&gt; variable_get('number_select', '20')