Advertisement
mihailmrom

Riddler

Jan 6th, 2015
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.52 KB | None | 0 0
  1. $query_header_by_cat = $this->db->query("SELECT id, coloane FROM categories WHERE id='".$categorie."'");
  2. $numrows_query_header_by_cat = $query_header_by_cat->num_rows();
  3. $results_query_header_by_cat = $query_header_by_cat->result_array();
  4.  
  5. foreach ($results_query_header_by_cat as $header_td) {
  6.     $cols_th = $header_td['coloane'];
  7.     $rows_th = explode(',', $cols_th);
  8. }  
  9.  
  10. $query_content_by_cat = $this->db->query("SELECT id, id_categorie, $cols_th, status
  11.                           FROM articles
  12.                           WHERE CONCAT($rows_th[0], ' ', $rows_th[1])
  13.                           LIKE '%$keyword%'
  14.                           AND id_categorie='$categorie'
  15.                         ");
  16. $numrows_query_content_by_cat = $query_content_by_cat->num_rows();
  17. $results_query_content_by_cat = $query_content_by_cat->result_array();
  18.  
  19. if ($numrows_query_content_by_cat > 0) {
  20.   echo '
  21.  <table class="table table-bordered">
  22.   <thead>
  23.    <tr>';
  24.      foreach($rows_th as $values_th) {
  25.     echo '<th>'.strtoupper(str_replace('_', ' ', $values_th)).'</th>';
  26.      }
  27.      print '<th>STATUS</th>';
  28.      if ($access <= 3) {
  29.        print '<th>ACTION</th>';
  30.      }
  31.      echo '
  32.    </tr>
  33.   </thead>
  34.   <tbody>';
  35.     foreach($results_query_content_by_cat as $values_td) {
  36.     echo '<tr id="'.$values_td['id'].'">';     
  37.     for($i=0; $i < count($rows_th); $i++) {
  38.         //print '<td id="'.$i.'">'.$values_td[''.$rows_th[$i].''].'</td>';
  39.         //print '<td id="'.$i.'">integer: '.$i.' <br /> result: '.$rows_th[$i].'</td>';
  40.  
  41.        ///*
  42.        if (is_string($values_td[''.$rows_th[$i].''])) {
  43.           print '<td id="'.$i.'">Value found!!!</td>';
  44.        } else {
  45.           print '<td id="'.$i.'">No luck...</td>';
  46.        }
  47.        //*/
  48.     }
  49.     echo '<td>'.$values_td['status'].'</td>';
  50.     if ($access <= 3) {
  51.        switch ($values_td['status']) {
  52.         default:
  53.             print '<td>Eroare</td>\n';
  54.         break;
  55.         case 'assign':
  56.             print '
  57.             <td align="center">
  58.              <a href="'.$this->config->item('base_url').'/action/info/'.$values_td['id'].'" class="btn btn-sm btn-info">Info</a>
  59.              <a href="'.$this->config->item('base_url').'/action/take/'.$values_td['id'].'" class="btn btn-sm btn-danger">Preia</a>
  60.                 </td>';
  61.         break;
  62.         case 'available':
  63.             print '
  64.             <td align="center">
  65.              <a href="'.$this->config->item('base_url').'/action/assign/'.$values_td['id'].'" class="btn btn-sm btn-success">Aloca</a>
  66.             </td>';
  67.         break;
  68.        }
  69.     }  
  70.     echo '</tr>';              
  71.     }
  72.     echo '
  73.   </tbody>
  74.  </table>';
  75. } else {
  76.   echo '<div class="alert alert-danger">Nu am gasit <b>'.$keyword.'</b> in categoria selectata!</div>';
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement