0
我知道有一個下拉菜單顯示了我的MYSQL表中的項目。現在它顯示了這些不同的名稱,但我怎樣才能得到我的代碼中的選定的項目。如何獲取所選下拉項目(ID錶行)PHP MYSQL
所以,如果我打開下拉菜單,我也得到例如項目3我可以做這個事情。 我想要的東西就像選擇了項目3 -vs-項目4並填寫form1比填寫form2高(>)。第3項增加3分,第4項0分。
希望你能幫上忙。
這是下拉菜單是代碼:
<select name="dropdown">
<option value=""></option>
<?php
mysql_data_seek($result, 0);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="">' . $row['Team'] . '</option>';
}
}
?>
</select>
<input style="width:20px; text-align:center;" type="text" name="hometeam" placeholder="0" />
-
<input style="width:20px; text-align:center;" type="text" name="awayteam" placeholder="0" />
<select name="dropdown">
<option value=""></option>
<?php
mysql_data_seek($result, 0);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="">' . $row['Team'] . '</option>';
}
}
?>
</select><br>
<select name="dropdown">
<option value=""></option>
<?php
mysql_data_seek($result, 0);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="">' . $row['Team'] . '</option>';
}
}
?>
</select>
這是我整個admin.php的
<?php
error_reporting(E_ALL^E_NOTICE);
if(!isset($_COOKIE['E2ingelogd'])) {
header("location:../../index.php");
}
$username = "root";
$password = "";
$hostname = "localhost";
$dbhandle = mysql_connect($hostname, $username, $password) or die("Kan niet inloggen");
$selected = mysql_select_db("login", $dbhandle);
if(isset($_POST['team'])){
$team = $_POST['team'];
$ID = $_POST['id'];
$query = mysql_query("SELECT * FROM e2teams WHERE Team='$team' and ID='$ID'");
if(mysql_num_rows($query) > 0) { //check if there is already an entry for that username
echo "$team bestaat al!";
}
if (!$_POST['team'])
{
echo('Foutmelding: Je bent vergeten een <b>team</b> in te vullen');
}
else{
mysql_query("INSERT INTO e2teams (Team) VALUES ('$team')");
header("location:e2admin.php");
}
}
mysql_close();
?>
<html><head>
<link href='http://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
<link href="../css/layout.css" rel="stylesheet" type="text/css"></head>
<body>
<div class="wrapper">
<div class="header">
<div class="logo"><img height="140" src="../images/boyslogo.png"> </div>
<div class="titelpagina">Vroomshoopse Boys E2 admin panel</div>
<div class="uitloggen"><a href="../../logout.php">Uitloggen</a></div>
</div>
<div class="content">
<div class="teamstoevoegenvak">
<div class="titelbalk">
<h1>Voeg teams toe</h1><br>
<form style="border:0px; width:400px; margin:0px; padding:0px;" action="e2admin.php" method="POST">
<input style="width=:100%;" type="text" name="team" placeholder="Team naam" /><br>
<input type="submit" value="Toevoegen" />
</form>
</div>
</div>
<div clas="toegevoegdeteamsvak">
<div class="titelbalktoege">
<h1>Toegevoegde teams</h1>
</div>
<div class="deteams">
<?php
$table = "e2teams";
$sql = "SELECT * FROM e2teams";
$result = mysql_query($sql, $dbhandle);
if(mysql_num_rows($result) > 0){
$team = array();
while($row = mysql_fetch_array($result)) {
echo "<table><tr><td class='styled-td'>";
echo $row['Team']. '</td><td></td><td width="50"><a href="edit.php?edit='.$row['ID'].'">Bewerk</a></td><td><a href="delete.php?del='.$row['ID'].'">Verwijder</a><br>';
echo "</td></tr></table>";
$team = $row['Team'];
}
}
mysql_data_seek($result, 0);
?>
</div>
</div>
<div class="titelbalkuitslagen">
<h1>Uitslagen</h1>
</div>
<div class="volgendewedstrijdvak">
<form action="" method="post">
<input style="width:410px;" type="text" name="date" placeholder="Datum" /><br>
<select name="dropdown">
<option value=""></option>
<?php
mysql_data_seek($result, 0);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="">' . $row['Team'] . '</option>';
}
}
?>
</select>
<input style="width:20px; text-align:center;" type="text" name="thuisteam" placeholder="0" />
-
<input style="width:20px; text-align:center;" type="text" name="uitteam" placeholder="0" />
<select name="dropdown">
<option value=""></option>
<?php
mysql_data_seek($result, 0);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="">' . $row['Team'] . '</option>';
}
}
?>
</select><br>
<select name="dropdown">
<option value=""></option>
<?php
mysql_data_seek($result, 0);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="">' . $row['Team'] . '</option>';
}
}
?>
</select>
<input style="width:20px; text-align:center;" type="text" name="hometeam" placeholder="0" />
-
<input style="width:20px; text-align:center;" type="text" name="awayteam" placeholder="0" />
<select name="dropdown">
<option value=""></option>
<?php
mysql_data_seek($result, 0);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="">' . $row['Team'] . '</option>';
}
}
?>
</select><br>
<select name="dropdown">
<option value=""></option>
<?php
mysql_data_seek($result, 0);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="">' . $row['Team'] . '</option>';
}
}
?>
</select>
<input style="width:20px; text-align:center;" type="text" name="thuisteam" placeholder="0" />
-
<input style="width:20px; text-align:center;" type="text" name="uitteam" placeholder="0" />
<select name="dropdown">
<option value=""></option>
<?php
mysql_data_seek($result, 0);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="">' . $row['Team'] . '</option>';
}
}
?>
</select><br>
<select name="dropdown">
<option value=""></option>
<?php
mysql_data_seek($result, 0);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="">' . $row['Team'] . '</option>';
}
}
?>
</select>
<input style="width:20px; text-align:center;" type="text" name="thuisteam" placeholder="0" />
-
<input style="width:20px; text-align:center;" type="text" name="uitteam" placeholder="0" />
<select name="dropdown">
<option value=""></option>
<?php
mysql_data_seek($result, 0);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="">' . $row['Team'] . '</option>';
}
}
?>
</select><br>
<select name="dropdown">
<option value=""></option>
<?php
mysql_data_seek($result, 0);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="">' . $row['Team'] . '</option>';
}
}
?>
</select>
<input style="width:20px; text-align:center;" type="text" name="thuisteam" placeholder="0" />
-
<input style="width:20px; text-align:center;" type="text" name="uitteam" placeholder="0" />
<select name="dropdown">
<option value=""></option>
<?php
mysql_data_seek($result, 0);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="">' . $row['Team'] . '</option>';
}
}
?>
</select><br>
<select name="dropdown">
<option value=""></option>
<?php
mysql_data_seek($result, 0);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="">' . $row['Team'] . '</option>';
}
}
?>
</select>
<input style="width:20px; text-align:center;" type="text" name="thuisteam" placeholder="0" />
-
<input style="width:20px; text-align:center;" type="text" name="uitteam" placeholder="0" />
<select name="dropdown">
<option value=""></option>
<?php
mysql_data_seek($result, 0);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="">' . $row['Team'] . '</option>';
}
}
?>
</select><br>
<input style="margin-left:330px;" type="submit" value="Toevoegen" />
</form>
</div>
</div>
</div>
</body>
</html>
謝謝!但如何將此鏈接到如果hometeam比表格中的點行高於+3以上的情況。取決於這兩個:_ _填寫表單? – AlexanderFT