Hallo Leute,
ich habe folgendes Problem:
Ich möchte auf meiner Seite per Dropdown (Produktauswahl)
das mit einer Mysql Datenbank verlinkt ist
und einem Feld bei dem man die Anzahl eintippenkann Datenbank Einträge updaten,
leider macht es für Alle Eintäge das selbe Update egal welches Produkt ausgewähl wurde.
Stimmt etwas mit meinem Updatebefhl nicht?
Ich bin wirklich ratlos :-(
Liebe Grüße
ich habe folgendes Problem:
Ich möchte auf meiner Seite per Dropdown (Produktauswahl)
das mit einer Mysql Datenbank verlinkt ist
und einem Feld bei dem man die Anzahl eintippenkann Datenbank Einträge updaten,
leider macht es für Alle Eintäge das selbe Update egal welches Produkt ausgewähl wurde.
Stimmt etwas mit meinem Updatebefhl nicht?
Ich bin wirklich ratlos :-(
Liebe Grüße
Code:
<?php
$server = "localhost";
$username = "***";
$passwd = "***";
$db = "***";
mysql_connect ($server, $username, $passwd);
mysql_select_db ($db);
$conn = mysql_connect($server, $username, $passwd);
mysql_select_db($db);
?>
<?php
if ($conn) {
$feedback = "Verbindung zum Datenbankserver wurde hergestellt.";
if (mysql_select_db("wi15")){
$feedback2 = "Verbindung zur Datenbank wurde hergestellt.";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="vorlage.css" />
<title>Titel</title>
</head>
<body>
<div id="wrapper">
<div id="header">
SAB - Warenwirtschaft
</div>
<div id='ueberschrift'>
<h1>Waren hinzufügen</h1>
</div>
<div id="menu_left">
<?php
include "navi.php";
?>
</div>
<div id="content">
<head>
<title> Waren hinzufügen</title>
</head>
<body>
<form name="Waren hinzufügen" method="post" action="inward.php">
<p align="center"> <font> Produktname: </font>
<select name=Produktname size= "1">
//Auswahl Dropdown & Anzahl
<?php
$dropdown = mysql_query("SELECT ID, Name FROM waren");
while ($row = mysql_fetch_array ($dropdown)){
echo "<option value=$row[0]>".$row[1] ."</option>"; }
?>
<br>
<br>
<hr>
</p>
<p align="center"> <font> Anzahl: </font> <input name="Bestand" type="integer(+)" Size="10"> </p>
<p align="center"> <input type="submit" name="eintragen" value ="Produkt hinzufugen"> </p>
</form> </select>
<?php
if(isset($_POST['eintragen'])){
$name = $_POST['Produktname'];
$bestand = $_POST ['Bestand'];
$sql = "UPDATE waren SET Bestand = Bestand+ $bestand WHERE( '$name','$bestand' )";
if (mysql_query($sql)) {
echo "Eintrag erfolgreich.";
}
else {
echo "Eintrag fehlgeschlagen." .mysql_error();
echo "<br>$sql";
}
}
?>
</div>
<div class="clear">
</div>
<div id="footer">
Annika
</div>
</div>
</body>
</html>