Code:
<!--**************Datenbank verbinden**************//-->
<?php
$db=mysql_connect("XXX", "XXX", "")or die(mysql_error());
mysql_select_db("Knowledgebase")or die(mysql_error());
$query = "SELECT * FROM Solutions WHERE ID ='".$id."'";
$result=mysql_query($query)or die(mysql_error());
$row = mysql_fetch_assoc($result);
?>
<!--**************Layout**************//-->
<form action="<?php echo $PHP_SELF; ?>" method="post" name="eintragung">
<p>Bitte Datensatz verändern!<br>
<table border="0">
<td align="left">Synopsis<br /><textarea name="synopsis" cols="20" rows="10"><?php echo $row['Synopsis']; ?></textarea>
<td align="left">Solution<br /><textarea name="solution" cols="20" rows="10"><?php echo $row['Solution']; ?></textarea>
<tr>
<tr>
<td>Typ</td>
<td><input type="text" name="entrytype" size="27" value="<?php echo $row['EntryType']; ?>" ></td></tr>
<tr>
<tr>
<td>Link</td>
<td><input type="text" name="link" size="27" value="<?php echo $row['Link']; ?>" ></td></tr>
<tr>
<td>Produkt</td>
<td><input type="text" name="product" size="27" value="<?php echo $row['Product']; ?>" ></td></tr>
<tr>
<td>Version</td>
<td><input type="text" name="version" size="27" value="<?php echo $row['Version']; ?>" ></td></tr>
<tr>
<td>Eintragsdatum</td>
<td><input type="text" name="datecreated" size="27" value="<?php echo $row['DateCreated']; ?>" ></td></tr>
<tr>
<td>Änderungsdatum</td>
<td><input type="text" name="datechanged" size="27" value="<?php echo $row['DateChanged']; ?>" ></td></tr>
<tr>
<td>Erstellt von</td>
<td><input type="text" name="personcreated" size="27" value="<?php echo $row['PersonCreated']; ?>" ></td></tr>
<tr>
<td>Geändert von</td>
<td><input type="text" name="personchanged" size="27" value="<?php echo $row['PersonChanged']; ?>" ></td></tr>
<tr>
<tr>
<td>Suchkriterium</td>
<td><input type="text" name="searchcriteria" size="27" value="<?php echo $row['SearchCriteria']; ?>" ></td></tr>
<tr>
<tr>
<td>Status</td>
<td><input type="text" name="entrystate" size="27" value="<?php echo $row['EntryState']; ?>" ></td></tr>
<tr>
</table>
<input type="submit" name="new" value="Speichern">
<input type="reset" value="Textfelder löschen">
</form>
<!--**************aktualisieren**************//-->
<?php
echo count($_POST);
if (count($_POST) > 0){
foreach($_POST as $key=>$value){
$key = trim(mysql_escape_string($value));
}
$sql ="UPDATE Solutions SET Synopsis ='".$synopsis."', EntryType ='".$entrytype."', Solution ='".$solution."', Link ='".$link."',
Product ='".$product."', Version = '".$version."', DateCreated ='".$datecreated."',DateChanged ='".$datechanged."',
PersonCreated = '".$personcreated."', PersonChanged ='".$personchanged."', SearchCriteria ='".$searchcriteria."',
EntryState='".$entrystate."' WHERE ID =".$id."";
echo $sql;
mysql_query($sql);
echo mysql_error();
}
echo "$sql";
?>
</body></html>
Habe den CODE ! ID wird von nem anderen Formular gesendet und die textfelder entsprechend gefüllt. Bei einer änderung eines textfeldes soll die Änderung gespeichert werden. Irgendwie stimmt da was nicht!