Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.08 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.  
  5. </head>
  6. <body>
  7.  
  8. <?php
  9.  
  10. require "mysql_con.php";
  11.  
  12. $str='';
  13. if( isset($_GET['q'])){
  14. $str= ($_GET['q']);
  15. }
  16.  
  17. $sql="SELECT TU.nome, A.cognome, A.ruolo, A.titolare
  18.                FROM teamutente AS TU JOIN
  19.                    (SELECT NBAPL.idnbaPlayer, NBAPL.cognome, NBAPL.ruolo, PIT.squadra, PIT.titolare
  20.                        FROM playerinteam AS PIT JOIN nbaplayer NBAPL
  21.                            ON PIT.player = NBAPL.idnbaPlayer) AS A
  22.                ON TU.idteamUtente = A.squadra
  23.                WHERE TU.nome='$str' AND A.titolare='1'
  24.                
  25.        ";
  26.  
  27. $result = mysqli_query($mysqli,$sql);
  28.  
  29. echo  "<form action=\"titolari.php\" method=\"POST\">";
  30.  
  31. while($row = mysqli_fetch_array($result)) {
  32.  
  33.     echo "  
  34.            <input type='checkbox' name='player[]' value='".$row['cognome']."'> ".$row['cognome']." ".$row['ruolo']."".$row['titolare']." <br>
  35.            
  36.    ";
  37. }
  38. echo "<input type=\"submit\" name=\"submit\">";
  39. echo " </form>";
  40.  
  41.  
  42.  
  43. $checkBox = isset($_POST['player']) ? $_POST['player'] : array();
  44.  
  45.  
  46.  
  47. if(isset($_POST['submit'])){
  48.  
  49.      for ($i=0; $i<sizeof($checkBox); $i++){
  50.  
  51.      
  52.             $findIdPL = "SELECT idnbaPlayer FROM nbaplayer WHERE cognome='$checkBox[$i]'";
  53.  
  54.            
  55.            // if ($mysqli->query($findIdPL) === TRUE) {
  56.             $result = $mysqli->query($findIdPL);
  57.             $rowPL = mysqli_fetch_row($result);
  58.             echo " id nba player ";
  59.             print_r($rowPL);
  60.            
  61.  
  62.             $findIdT = "SELECT idteamUtente FROM teamutente WHERE nome='$str'";
  63.            
  64.             //if ($mysqli->query($findIdT) === TRUE) {
  65.             $result = $mysqli->query($findIdT);
  66.             $rowT = mysqli_fetch_row($result);
  67.             echo "id team in cui inserirlo ";
  68.             print_r($rowT);
  69.             echo "  ";
  70.            
  71.  
  72.             //$query="INSERT INTO playerinteam VALUES ('" .$rowPL[0] . "','" .$rowT[0] . "', '1')";    
  73.            
  74.          
  75.            echo $checkBox[$i];
  76.            
  77.         }
  78.  
  79. }  
  80.  
  81. ?>
  82.  
  83. </body>
  84.  
  85. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement