我知道有一个下拉菜单显示我的MYSQL表中的项目。现在它显示了这些不同的名称,但我如何在我的代码中获取所选项目。
所以,如果我打开下拉列表,我得到例如item3,我可以用这个做点什么。 我想要的是,如果选择了项目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>
答案 0 :(得分:0)
您需要在value=""
的{{1}}部分放置一些内容,这些内容是$ _POST或$ _GET中返回的内容。
您可以在其中放置任何内容,通常是包含['Team']名称的行的ID,但它可以是任何内容,例如:
<option
或
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['ID'] . '">' . $row['Team'] . '</option>';
}
}