dimanche 7 décembre 2014

Get id connected to the chosen name php


Vote count:

0




I'm new to php and trying to create a add_player page. First of all i've created a select query which is suppose to select the different teams which will be used in a dropdown field. This query works fine and you can see it below.



$getQuery = "SELECT Teams.name as 'teamName', Games.name as 'gameName', Subteams.id as 'teamId' FROM Subteams, Teams, Games WHERE Subteams.gameId = Games.id AND subteams.teamId = teams.id ORDER BY Teams.name" or die("Error in the consult.." . mysqli_error($link));

$result = $link->query($getQuery);


Then i've created a form which include the name, country, birthday and team. What i've done is using post statements to try and add the variables to the link but it does not seem to add the form values in the link. Beside that i cant seem to figure out how i can add the teamId? the teamId is connected to the team field?



<form role="form">
<div class="form-group">

<input type="text" class="form-control" name="name" placeholder="Name">
</div>
<div class="form-group">

<input type="text" class="form-control" name="country" placeholder="Country">
</div>
<div class="form-group">
<input type="text" class="form-control" name="birthday" placeholder="YYYY-MM-DD">
</div>



<div class="form-group">

<select class="form-control" id="team">

<?

while($row = mysqli_fetch_array($result)) {
echo"<option>" . $row["teamName"] . " (" . $row["gameName"] . ")</option>";

}
?>

</select>
</div>
<?
$name = $_POST['name'];
$country = $_POST['country'];
$birth = $_POST['birthday'];
$team = $_POST['team'];
echo"<a type='submit' class='btn btn-default'href='add_player.php?name=" . $name . "&country=" . $country . "&birthday=". $birthday ."&teamId=". $teamId(HOW?) ."'>Submit</a>";
echo"<a type='submit' class='btn btn-default pull-right' href=\"javascript:history.go(-1)\">Cancel</a>";


?>
</form>


asked 1 min ago







Get id connected to the chosen name php

Aucun commentaire:

Enregistrer un commentaire