Doubt Mysql + PHP

0

Hello, I'm developing an online management system (fifa, pes) and I'm having a problem, now I'm doing the part where the user will post the result of the game, informing the scoreboard and the players who made the goals , for this I need to access the database and select the list of players of the user's club and put them in a button in the form of select pro user only click, I am beginner would like to know how I do this, with which function, follows example of my code where I could get the DB data

<?php
$link = mysqli_connect("localhost", "root", "usbw", "mith");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}
$query = "
SELECT C.nome_clube , J.nome_jogador
  FROM clube as C 
 RIGHT OUTER JOIN conta_user as UC ON C.id_clube = UC.id_conta
 RIGHT OUTER JOIN jogador as J ON C.id_clube = J.id_jogador";

if ($result = mysqli_query($link, $query)) {

    /* fetch associative array */
    while ($row = mysqli_fetch_assoc($result)) {
        printf ("%s (%s)\n", $row["nome_clube"], $row["nome_jogador"]);
    }

    /* free result set */
    mysqli_free_result($result);
}

/* close connection */
mysqli_close($link);
?>
    
asked by anonymous 18.05.2017 / 23:27

1 answer

0

If I understand right you want to make a select field in html with the values of the database, if that would be the case, where the value of the options would be the id for you to retrieve per post or javascript and manipulate as you want:

<select name="JOGADOR" id="JOGADOR" >
      <?php do { ?>
        <option value="<?php echo $row['id_jogador']; ?>">
          <?php echo $row['nome_jogador'];?>
        </option>
      <?php  } while ($row = mysqli_fetch_assoc($result)); ?>
</select>
    
19.05.2017 / 02:34