...
...
3 svar · 263 visningar · startad av Coper
...
borde funka nu:
<html>
<body>
<?php
$db_=_mysql_connect("localhost",_"root");
mysql_select_db("mydb",$db);
if_(isset($_GET['id']) ||_isset($_POST['id']))
{
if_($_POST['submit'])
{
$sql_=_"UPDATE_employees_SET first='".$_POST['first']."',last='".$_POST['last']."',address='".$_POST['address']."',position='".$_POST['$position']."'_WHERE_id=".$_POST['id'];
$result_=_mysql_query($sql);
echo_"Thank you! Information updated.\n";
}_
else_
{
// query the DB
$sql_=_"SELECT_*_FROM_employees_WHERE_id=".$_POST['id'];
$result_=_mysql_query($sql);
$myrow_=_mysql_fetch_array($result);
?>
<form method="post" action="<?php_echo_$PHP_SELF?>">
<input type=hidden name="id" value="<?php_echo_$myrow["id"]_?>">
First name:<input type="Text" name="first" value="<?php_echo_$myrow["first"]_?>"><br>
Last name:<input type="Text" name="last" value="<?php_echo_$myrow["last"]_?>"><br>
Address:<input type="Text" name="address" value="<?php_echo_$myrow["address"]_?>"><br>
Position:<input type="Text" name="position" value="<?php_echo_$myrow["position"]_?>"><br>
<input type="Submit" name="submit" value="Enter information">
</form>
<?php
}
}
else
{
// display list of employees
$result_=_mysql_query("SELECT * FROM employees",$db);
while_($myrow_=_mysql_fetch_array($result))
{
printf("<a href=\"%s?id=%s\">%s %s</a><br>\n",_$PHP_SELF,_$myrow["id"],_$myrow["first"],_$myrow["last"]);
}
}
?>
</body>
</html>
...
Hmm.. det blev en massa _ streck överallt... Bort!