Möchte verschiedene werte von select feldern in eine db eintragen,
wie ist das mit einem submit button am besten realisierbar?
wie ist das mit einem submit button am besten realisierbar?
<?php
$sql = "INSERT INTO
db(test, test2)
VALUES
('".trim($_POST['textbox'])."', '".trim($_SESSION['was anderes'])."');";
$result = mysql_query($sql) OR die(mysql_error());
echo "
\n";
echo " hinzugefügt.\n";
echo "</p>\n";
echo "[*]\n";
$sql = "SELECT
test, test2
FROM
db
WHERE
id = '".$_SESSION['id']."'
ORDER BY
test ASC;";
$result = mysql_query($sql) OR die(mysql_error());
echo "
\n";
while($row = mysql_fetch_assoc($result)){
echo "<a>".$row['sub']."</a>
";
}
echo " \n";
?>
<?php
session_start();
if(!isset($_SESSION['manager'])) {
header("location:index.php");
die;
}
include("connect.inc.php");
require("config.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>aufstellung</title>
</head>
<body>
<table style="text-align: left; width: 1203px; height: 92px;"
border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</p>
<table width="100%" border="1">
<tr>
<td width="18%" height="923" valign="top"><table width="93%" border="1">
<tr>
<td height="40"><div align="center">Büro</div></td>
</tr>
<tr>
<td height="40"><div align="center">Aufstellung</div></td>
</tr>
<tr>
<td height="40"><div align="center">Kader</div></td>
</tr>
<tr>
<td height="40"><div align="center">Jugend</div></td>
</tr>
<tr>
<td height="40"><div align="center">Transfermarkt</div></td>
</tr>
<tr>
<td height="40"><div align="center">Arbeitsmarkt</div></td>
</tr>
<tr>
<td height="40"><div align="center">Tabelle</div></td>
</tr>
<tr>
<td height="40"><div align="center">Ligaspiele</div></td>
</tr>
</table></td>
<?php
$sql = "SELECT * FROM spieler WHERE manager='".$_SESSION["manager"]."' ORDER BY position DESC, staerke DESC, spielername ASC";
$result = MYSQL_QUERY($sql);
if(!$result) echo MYSQL_ERROR();
// Anzahl der Datensätze
$num = mysql_num_rows($result);
?>
<?php if(!isset($_POST['submit'])) { ?>
<td width="82%" align="left" valign="top"><table width="100%" border="1">
<tr>
<td width="19%"></td>
<td width="28%">Name</td>
<td width="7%">Pos.</td>
<td width="6%">Alt.</td>
<td width="6%">Stärke</td>
<td width="5%">Mot.</td>
<td width="12%">Aufstellung</td>
<td width="17%"></td>
</tr>
<?php
// Schleife
for ($i=1; $i<=$num; $i++) {
// Datensatz in die Variable $row zuweisen
$row = mysql_fetch_assoc($result);
?>
<tr>
<td></td>
<td><?php echo $row['spielername']; ?></td>
<td><?php echo $row['position']; ?></td>
<td><?php echo $row['alter']; ?></td>
<td><?php echo $row['staerke']; ?></td>
<td><?php echo $row['moti']; ?></td>
<td>
<form action="select.php" method="post">
<select size="1" name="aufstellung">
<option value="0" >-
<option value="1">TW
<option value="2" >VERT
<option value="3" >MF
<option value="4" >ANG
</select></form></td>
<td></td>
</tr>
<?php
}
?>
</table>
<table width="100%" border="1">
<tr>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="44%"></td>
<td width="41%"><input type="submit" name="submit" value="Aufstellung übernehmen" class="button"></td>
</tr>
</table>
</td>
</table>
<?php
}
else
$eintrag = $_POST['aufstellung'];
$sql = mysql_query("UPDATE spieler SET auf.="$eintrag" WHERE manager='".$_SESSION["manager"]."'");
?>
<h1 align="left" style="font-weight: normal;">
</h1>
</body>
</html>
Kommentar