www.webdeveloper.com
Results 1 to 5 of 5

Thread: Array PhP

  1. #1
    Join Date
    Jan 2014
    Posts
    12

    Wink Array PhP

    I can make this script show me all numbers ($search_text) in one row

    it is something like this :

    PHP Code:
    Nr.     Aparitii     Pauza     Pauza max.     Media
    22    10            1            19                      33.33
    %
    23    8            2            11                      12.12

    i want something like this :


    PHP Code:
    Nr.     Aparitii     Pauza     Pauza max.     Media
    22
    ,23    5            2            19                      12.33

    Can anybody help me?
    PHP Code:
    <?php
    mysql_connect
    ("mysql.hostinger.ro""u433511535_loto""password") or die(mysql_error());
    mysql_select_db("u433511535_loto") 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;
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" href="style.css" type="text/css" media="all" />
        <script src="js/sorttable.js"></script>
        <title>Loto Polonia</title>
    </head>
    <body>

    <div id="search">
        <form method="post" action="index.php">
            <input type="text" placeholder="Numere" name="numere" size="30" value="<?php echo $search_text?>">
            <input type="text" placeholder="Extrageri" name="extrageri" size="5" value="<?php echo $limit?>">
            <select name="ultimele_zile">
                <option value="1">Ultima zi</option>
                <option value="2">Ultimele 2 zile</option>
                <option value="3" selected="selected">Ultimele 3 zile</option>
                <option value="4">Ultimele 4 zile</option>
                <option value="5">Ultimele 5 zile</option>
                <option value="0">Toată baza de date</option>
            </select>
            <input type="submit" value="Caută">
        </form>    
    </div>


    <table id="box-table-a" class="sortable" style="float: left; margin: 0 15px 15px 0; text-align: center;">
        <thead>
            <tr>
                <th scope="col">Nr.</th>
                <th scope="col">Aparitii</th>
                <th scope="col">Pauza</th>
                <th scope="col">Pauza max.</th>
                <th scope="col">Media</th>
            </tr>
        </thead>
        <tbody>
            <?php
            
    if (is_array($numere_cautate)) {
                
    $cu_limita = ($ultimele_zile == 0) ? "" "AND data >= (CURDATE() - INTERVAL $ultimele_zile DAY )";
                
                foreach (
    $numere_cautate as $numar_cautat) {
                    echo 
    '<tr>';
                    echo 
    '<td>'.$numar_cautat.'</td>';
                    echo 
    '<td>';            
                    
    $aparitii mysql_num_rows(mysql_query("SELECT * FROM extrageri WHERE FIND_IN_SET('".$numar_cautat."', numere) > 0 ".$cu_limita." ORDER BY id DESC "));
                    echo 
    $aparitii;
                    echo 
    '</td>';
                    
                    
    $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 $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_extrageri2);
                    echo 
    '<td>'.$pauza_curenta.'</td>';
                    echo 
    '<td>'.$pauza_maxima.'</td>';
                    echo 
    '<td>'.$medie.'%</td>';
                    echo 
    '</tr>';    
                }
            }
               
    ?>
        </tbody>
    </body>
    </html>

  2. #2
    Join Date
    Jan 2014
    Posts
    12
    I don't know how to edit my post this is sql

    PHP Code:
    -- phpMyAdmin SQL Dump
    -- version 4.0.9
    -- http://www.phpmyadmin.net
    --
    -- 
    Gazda127.0.0.1
    -- Timp de generare23 Ian 2014 la 06:58
    -- Versiune server5.6.14
    -- Versiune PHP5.5.6

    SET SQL_MODE 
    "NO_AUTO_VALUE_ON_ZERO";
    SET time_zone "+00:00";


    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
    /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
    /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
    /*!40101 SET NAMES utf8 */;

    --
    -- 
    Baz&#259; de date: `loto_polonia`
    --

    -- --------------------------------------------------------

    --
    -- 
    Structura de tabel pentru tabelul `extrageri`
    --

    CREATE TABLE IF NOT EXISTS `extrageri` (
      `
    idint(11NOT NULL AUTO_INCREMENT,
      `
    datadate NOT NULL,
      `
    numerevarchar(255NOT NULL,
      
    PRIMARY KEY (`id`)
    ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=31 ;

    --
    -- 
    Salvarea datelor din tabel `extrageri`
    --

    INSERT INTO `extrageri` (`id`, `data`, `numere`) 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,penis,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');

    /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
    /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
    /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */

  3. #3
    Join Date
    Jan 2014
    Posts
    12

    Update

    First mysql is not good this is it

    DataBase: `u433511535_loto`


    PHP Code:
    -- phpMyAdmin SQL Dump
    -- version 3.5.2.2
    -- http://www.phpmyadmin.net
    --
    -- 
    Gazdalocalhost
    -- Timp de generare27 Ian 2014 la 23:08
    -- Versiune server5.1.69
    -- Versiune PHP5.2.17

    SET SQL_MODE
    ="NO_AUTO_VALUE_ON_ZERO";
    SET time_zone "+00:00";


    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
    /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
    /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
    /*!40101 SET NAMES utf8 */;

    --
    -- 
    Baza de date: `u433511535_loto`
    --

    -- --------------------------------------------------------

    --
    -- 
    Structura de tabel pentru tabelul `extrageri`
    --

    CREATE TABLE IF NOT EXISTS `extrageri` (
      `
    idint(11NOT NULL AUTO_INCREMENT,
      `
    datadate NOT NULL,
      `
    numerevarchar(255NOT NULL,
      
    PRIMARY KEY (`id`)
    ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=31 ;

    --
    -- 
    Salvarea datelor din tabel `extrageri`
    --

    INSERT INTO `extrageri` (`id`, `data`, `numere`) 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');

    /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
    /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
    /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */

  4. #4
    Join Date
    Jan 2014
    Posts
    12
    can anybody help me ?

  5. #5
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,537
    I'm not really sure what the business logic is, but you probably want to use some sort or GROUP BY clause in your DB query, along with the assorted aggregate functions to get the desired values for each result row field. (See the GROUP_CONCAT() function for combining those first values into a comma-delimited string.)
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles