title: [PHP-Array]Group Script
body: <p>Hey stackoverflow comunity i have this script to search a MySQL database, this script shows me how many times one number was extracted from the loto extraction. I don't know how to make it search for number groups like 22,69,80.</p>
  
  <p><strong>What this script shows:</strong> </p>
  
  <p><a href="http://i.stack.imgur.com/i8wof.png" rel="nofollow">http://i.stack.imgur.com/i8wof.png</a></p>
  
  <p><strong>Script:</strong></p>
  
  <pre><code>&lt;?php
  mysql_connect("mysql.hostinger.ro", "******", "*****") or die(mysql_error());
  mysql_select_db("*******") or die(mysql_error());
  
  $numere_cautate = false;
  if (isset($_POST['numere'])) {
      $search_text = str_replace(" ", "", trim($_POST['numere']));
      if (!empty($search_text)) {
          $numere_cautate = explode(",", $search_text);
      }
  }
  
  $search_text = isset($search_text) ? $search_text : "";
  
  $limit = isset($_POST['extrageri']) ? $_POST['extrageri'] : 10;
  $limit = is_numeric($limit) ? $limit : 10;
  
  $ultimele_zile = isset($_POST['ultimele_zile']) ? $_POST['ultimele_zile'] : 3;
  $ultimele_zile = is_numeric($ultimele_zile) ? $ultimele_zile : 3;
  ?&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
      &lt;link rel="stylesheet" href="style.css" type="text/css" media="all" /&gt;
      &lt;script src="js/sorttable.js"&gt;&lt;/script&gt;
      &lt;title&gt;Loto Polonia&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div id="search"&gt;
      &lt;form method="post" action="index.php"&gt;
          &lt;input type="text" placeholder="Numere" name="numere" size="30" value="&lt;?php echo $search_text; ?&gt;"&gt;
          &lt;input type="text" placeholder="Extrageri" name="extrageri" size="5" value="&lt;?php echo $limit; ?&gt;"&gt;
          &lt;select name="ultimele_zile"&gt;
              &lt;option value="1"&gt;Ultima zi&lt;/option&gt;
              &lt;option value="2"&gt;Ultimele 2 zile&lt;/option&gt;
              &lt;option value="3" selected="selected"&gt;Ultimele 3 zile&lt;/option&gt;
              &lt;option value="4"&gt;Ultimele 4 zile&lt;/option&gt;
              &lt;option value="5"&gt;Ultimele 5 zile&lt;/option&gt;
              &lt;option value="0"&gt;Toată baza de date&lt;/option&gt;
          &lt;/select&gt;
          &lt;input type="submit" value="Caută"&gt;
      &lt;/form&gt;    
  &lt;/div&gt;
  
  
  &lt;table id="box-table-a" class="sortable" style="float: left; margin: 0 15px 15px 0; text-align: center;"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th scope="col"&gt;Nr.&lt;/th&gt;
              &lt;th scope="col"&gt;Aparitii&lt;/th&gt;
              &lt;th scope="col"&gt;Pauza&lt;/th&gt;
              &lt;th scope="col"&gt;Pauza max.&lt;/th&gt;
              &lt;th scope="col"&gt;Media&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;?php
          if (is_array($numere_cautate)) {
              $cu_limita = ($ultimele_zile == 0) ? "" : "AND data &gt;= (CURDATE() - INTERVAL $ultimele_zile DAY )";
  
              foreach ($numere_cautate as $numar_cautat) {
                  echo '&lt;tr&gt;';
                  echo '&lt;td&gt;'.$numar_cautat.'&lt;/td&gt;';
                  echo '&lt;td&gt;';            
                  $aparitii = mysql_num_rows(mysql_query("SELECT * FROM extrageri WHERE FIND_IN_SET('".$numar_cautat."', numere) &gt; 0 ".$cu_limita." ORDER BY id DESC "));
                  echo $aparitii;
                  echo '&lt;/td&gt;';
  
                  $prima_pauza = false;
                  $pauza = $pauza_curenta = $pauza_maxima = 0;            
                  $ultimele_extrageri = mysql_query("SELECT * FROM extrageri WHERE id ".$cu_limita." ORDER BY id DESC");
                  $numar_ultimele_extrageri = mysql_num_rows($ultimele_extrageri);
                  while ($rand = mysql_fetch_assoc($ultimele_extrageri)) {
                      $numere = str_replace(" ", "", $rand['numere']);
                      $numere_array = explode(",", $numere);
  
                      if (!in_array($numar_cautat, $numere_array)) {
                          $pauza++;    
                          if ($pauza &gt; $pauza_maxima) $pauza_maxima = $pauza;    
                      } else {
                          if ($prima_pauza == false) {
                              $pauza_curenta = $pauza;
                              $prima_pauza = true;
                              $pauza = 0;
                          }
                      }            
  
                      if ($aparitii == 0) $pauza_curenta = $pauza_maxima = $numar_ultimele_extrageri;
                  }
                  $medie = number_format(($aparitii * 100)/$numar_ultimele_extrageri, 2);
                  echo '&lt;td&gt;'.$pauza_curenta.'&lt;/td&gt;';
                  echo '&lt;td&gt;'.$pauza_maxima.'&lt;/td&gt;';
                  echo '&lt;td&gt;'.$medie.'%&lt;/td&gt;';
                  echo '&lt;/tr&gt;';    
              }
          }
             ?&gt;
      &lt;/tbody&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/i8wof.png" rel="nofollow">http://i.stack.imgur.com/i8wof.png</a>
  This is mysql dump</p>
  
  <blockquote>
    <p>SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00";</p>
    
    <p>/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT <em>/;
    /</em>!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS <em>/;
    /</em>!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION <em>/;
    /</em>!40101 SET NAMES utf8 */;</p>
    
    <p>--</p>
    
    <h2>-- Bază de date: <code>loto_polonia</code></h2>
    
    <hr>
    
    <p>--</p>
    
    <h2>-- Structura de tabel pentru tabelul <code>extrageri</code></h2>
    
    <p>CREATE TABLE IF NOT EXISTS <code>extrageri</code> (   <code>id</code> int(11) NOT NULL
    AUTO_INCREMENT,   <code>data</code> date NOT NULL,   <code>numere</code> varchar(255) NOT
    NULL,   PRIMARY KEY (<code>id</code>) ) ENGINE=InnoDB  DEFAULT CHARSET=utf8
    AUTO_INCREMENT=31 ;</p>
    
    <p>--</p>
    
    <h2>-- Salvarea datelor din tabel <code>extrageri</code></h2>
    
    <p>INSERT INTO <code>extrageri</code> (<code>id</code>, <code>data</code>, <code>numere</code>) VALUES (1,
    '2014-01-08',
    '6,9,10,12,14,25,27,30,32,33,34,41,43,50,51,56,59,68,73,74'), (2,
    '2014-01-08',
    '6,7,8,11,18,20,24,25,31,45,48,50,51,53,61,67,69,72,75,80'), (3,
    '2014-01-09',
    '4,5,6,7,12,19,22,28,32,36,44,48,52,53,57,58,66,74,77,penis'), (4,
    '2014-01-09',
    '3,5,6,8,9,13,14,19,26,31,34,41,42,50,54,59,63,67,73,77'), (5,
    '2014-01-10',
    '4,5,7,11,15,17,20,22,24,25,31,32,35,41,42,55,60,62,69,75'), (6,
    '2014-01-10',
    '1,6,11,12,13,15,19,27,28,31,34,35,40,43,49,51,52,64,66,71'), (7,
    '2014-01-11',
    '8,14,21,23,24,28,31,33,39,44,47,48,58,62,64,67,70,71,78,80'), (8,
    '2014-01-11',
    '5,8,15,24,31,35,37,39,40,42,47,51,57,58,63,68,70,75,76,78'), (9,
    '2014-01-12',
    '1,3,10,11,12,24,31,38,41,48,52,53,56,58,62,64,73,74,75,78'), (10,
    '2014-01-12',
    '2,6,9,13,17,21,29,44,50,53,54,56,58,59,65,66,70,71,72,76'), (11,
    '2014-01-13',
    '9,10,11,12,15,16,23,26,32,33,34,43,45,49,60,67,69,72,74,78'), (12,
    '2014-01-13',
    '4,9,17,18,22,23,25,27,30,31,32,37,44,51,52,55,66,70,71,72'), (13,
    '2014-01-14',
    '3,8,16,18,25,26,29,38,41,44,51,54,57,64,66,69,71,76,77,79'), (14,
    '2014-01-14',
    '6,7,16,22,24,26,28,35,37,43,46,54,55,58,69,70,71,73,77,79'), (15,
    '2014-01-15',
    '4,5,6,10,11,20,23,25,27,28,30,31,37,39,41,53,55,57,70,71'), (16,
    '2014-01-15',
    '5,7,10,14,15,19,28,30,36,37,38,45,52,57,58,66,67,72,75,76'), (17,
    '2014-01-16',
    '4,6,8,9,10,22,25,34,36,37,40,42,44,47,49,51,58,63,70,73'), (18,
    '2014-01-16',
    '7,8,9,10,14,22,23,26,27,29,30,32,48,55,57,58,62,65,67,75'), (19,
    '2014-01-17',
    '2,5,8,13,15,22,24,38,41,43,50,56,60,62,64,67,72,74,75,77'), (20,
    '2014-01-17',
    '1,6,13,14,19,21,24,25,30,33,38,44,47,49,54,56,57,63,77,80'), (21,
    '2014-01-18',
    '2,5,7,10,15,21,26,27,34,36,43,47,50,52,59,68,72,74,76,77'), (22,
    '2014-01-18',
    '12,14,17,21,23,27,33,34,35,38,53,57,58,63,64,66,69,70,74,75'), (23,
    '2014-01-19',
    '2,4,6,9,17,20,21,30,31,34,36,37,41,49,60,66,67,68,69,78'), (24,
    '2014-01-19',
    '1,17,18,25,27,30,32,35,36,37,41,48,55,58,59,64,69,71,72,77'), (25,
    '2014-01-20',
    '10,12,14,16,19,20,21,24,29,36,43,46,52,53,55,56,61,63,64,79'), (26,
    '2014-01-20',
    '2,6,7,14,20,21,22,26,35,43,44,46,47,50,59,60,63,64,72,76'), (27,
    '2014-01-21',
    '7,9,10,11,12,15,18,24,25,39,44,51,54,55,56,57,60,66,74,77'), (28,
    '2014-01-21',
    '3,9,14,15,22,30,39,40,50,52,55,56,59,60,68,69,71,75,79,80'), (29,
    '2014-01-22',
    '1,15,17,18,19,22,23,25,27,36,39,51,53,54,56,60,61,62,69,74'), (30,
    '2014-01-22',
    '2,4,8,16,21,25,27,31,40,45,47,52,54,56,59,62,69,71,73,77');</p>
    
    <p>/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT <em>/;
    /</em>!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS <em>/;
    /</em>!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;</p>
  </blockquote>