vishnu3006

AKC checkbox example

Sep 8th, 2011
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. <?php
  2. function featured_product_form() {
  3.     $query = “SELECT p.*, UNIX_TIMESTAMP(p.create_date) AS create_date, c.name FROM {product} p LEFT JOIN {category} c ON p.cid = c.cid
  4.     WHERE p.status = 1 ORDER BY p.product_name”;
  5.     $rs = db_query($query);
  6.  
  7.     $featured_products = featured_product();
  8.     $status = array();
  9.  
  10.     if ($rs) {
  11.         while ($data = db_fetch_object($rs)) {
  12.             $options[$data->productid] =;
  13.  
  14.             $form[$data->productid]['name'] = array(#value’ => stripslashes($data->product_name));
  15.            $form[$data->productid]['category'] = array(#value’ => stripslashes($data->name));
  16.            $form[$data->productid]['discount'] = array(#value’ => $data->discount . ‘%’);
  17.            $form[$data->productid]['createdon'] = array(#value’ => date(’m-d-Y’, $data->create_date));
  18.    
  19.             if (in_array($data->productid, $featured_products)) {
  20.                 $status[] = $data->productid;
  21.             }
  22.         }
  23.     }
  24.  
  25.     $form['featured'] = array(
  26.         ‘#type’ => ‘checkboxes’,
  27.         ‘#options’ => $options,
  28.         ‘#default_value’ => $status,
  29.     );
  30.  
  31.     $form['submit'] = array(
  32.         ‘#type’ => ’submit’,
  33.         ‘#value’ => t(’Submit’),
  34.     );
  35.  
  36.     $form['cancel'] = array(
  37.         ‘#type’ => ‘markup’,
  38.         ‘#value’ => l(t(’Cancel’), ‘dashboard’),
  39.     );
  40.  
  41.     $form['#redirect'] = ‘featured_product_mgmt’;
  42.  
  43.     return $form;
  44. }
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment