Mit første script. Update Database
Ja. Det er mig igen;-)Jeg har et mindre problem med update.
Jeg har forsøgt at lave en update af i en database. Men da jeg ikke har noget tourital til det, har jeg prøvet at forestille mig hvordan sådan en sql setning skulde se ud.
-- Script Start --
<html><head><title>look into command</title></head>
<body>
<h2><center>Look into Selected command</center></h2>
<?php
mysql_connect(\"localhost\",\"root\",\"\");
mysql_select_db(\"test\");
if ($update == \"\") {
$q = \"select * from $table where id=$id\";
$res = mysql_query($q);
$id = mysql_result($res,0,\"id\");
$command = mysql_result($res,0,\"command\");
$describ = mysql_result($res,0,\"describ\");
echo \"<center><table width=\'80%\'><tr><td width=\'30%\'>Command</td><td width=\'70%\'>Describtion</td></tr>\";
echo \"<tr><td width=\'30%\'>$command</td><td>$describ</td></tr><p><p>\";
echo \"<form action=\'phpsel.php\' methoed=\'post\'><tr><td width=\'30%\'><input type=\'tekst\' name=\'command2\' value=\'$command\'></td><td width=\'70%\'><textarea cols=\'55\' name=\'describ2\'>$describ</textarea><input type=\'hidden\' name=\'update\' value=\'yes\'><input type=\'hidden\' name=\'table\' value=\'$table\'><input type=\'hidden\' name=\'id\' value=\'$id\'></td></tr></table><input type=\'submit\' value=\'Update\'></form></center>\";
} else if ($update == \"yes\") {
$q = \"update $table set command=\'$command2\', describ=\'$describ2 where id=$id\";
mysql_query($q);
echo \"<center><a href=\'phpsel.php?table=$table&id=$id\'>Updatere</a></center>\";
}
mysql_close();
?>
</body></html>
-- Script Slut --
