www.webdeveloper.com
Results 1 to 3 of 3

Thread: PHP Script : Search from mysql numbers

Hybrid View

  1. #1
    Join Date
    Jan 2014
    Posts
    12

    Wink PHP Script : Search from mysql numbers

    Hey guys i need a script with search value from mysql table i try to make some but i don't have knowledge to write this script...
    I know how will sound this .. but i need this script for lotto ) the extraction is 20/80 numbers (1,2,3,4...80) and i need to know the combination number probability .

    Here is my tabel structure

    http://imagizer.imageshack.us/v2/800...0/607/32wo.png


    And this is how i thought this script must look

    http://imagizer.imageshack.us/v2/800...0/844/p1tv.png

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,611
    You'd probably be better off using two DB tables. One would hold the basic information about one lottery drawing, and the other would have one row per number drawn, with a foreign key to the first table, something like:
    Code:
    drawing
    =======
    drawing_id (INT, PRIMARY KEY, AUTO-INCREMENT)
    drawing_date
    drawing_time
    
    number_drawn
    =============
    drawing_id (INT, FOREIGN KEY TO drawing.drawing_id)
    number (INT)
    Then if you want to search for which drawings included 3 numbers (12, 17, and 25 in this example):
    Code:
    SELECT drawing.*
    FROM drawing
    INNER JOIN number_drawn AS nd1 USING(drawing_id)
    INNER JOIN number_drawn AS nd2 USING(drawing_id)
    INNER JOIN number_drawn AS nd3 USING(drawing_id)
    WHERE nd1.number = 12
      AND nd2.number = 17
      AND nd3.number = 25
    "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

  3. #3
    Join Date
    Jan 2014
    Posts
    12
    PHP Code:
    <?php  
        $conn 
    mysql_connect('IP''root''PASSWORD');
         if (!
    $conn)
        {
         die(
    'Could not connect: ' mysql_error());
        }
        
    mysql_select_db("loto"$conn);
    ?>
    PHP Code:
    <!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=iso-8859-1" />
    <login>Inregistreaza Numere:</login>
    </head>

    <body>
    <form method="post">
    <table>

        <tr>
            <td>Select  ID:</td>
            <td><input type="text" name="id" /></td>
        </tr>
        <tr>
            <td>Number</td>
            <td><input type="text" name="number" /></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td><input type="submit" name="submit" value="add" /></td>
        </tr>
    </table>
    <?php
    if (isset($_POST['submit']))
        {       
        include 
    'db.php';
        
                         
    $id=$_POST['id'] ;
                        
    $number$_POST['number'] ;                    
                                                    
             
    mysql_query("INSERT INTO `number_drawn`(id,number) 
             VALUES ('
    $id','$number')"); 
                    
                    
                }
    ?>
        
                <?php
                
    include("db.php");
                                
    SELECT drawing.*
    FROM drawing
    INNER JOIN number_drawn 
    AS nd1 USING(drawing_id)
    INNER JOIN number_drawn AS nd2 USING(drawing_id)
    INNER JOIN number_drawn AS nd3 USING(drawing_id)
    WHERE nd1.number 12
      
    AND nd2.number 17
      
    AND nd3.number 25
                                        
                    
    echo "</tr>";
                }
                
    mysql_close($conn);
                
    ?>

    </body>
    </html>
    I don't know how i integrate your code ... can anyone help me?

    PHP Code:
    Parse errorsyntax errorunexpected T_STRING in /home/u433511535/public_html/loto/test/index.php on line 51 

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