rent php/html update form spg.
Hej!Jeg har en php side hvor jeg præsentere data i nogle input tedstbokse. Dette gør for dig jeg gerne vil lave en update knap der opdatere i db hvis jeg ændrfe i en tekstbox og trykker på knappen update.
Mit problem er at jeg kan sagtens putte det hele ind i en form og kalde et andet php script og derved opdatere men record.
Men jeg ville jo gerne hvsi man kunne laver det så smart at jeg kunne blive på siden og bare kalde en function med de rette parametre og opdatere on the fly.. Mit script er ret stort og ret rodet. Men her er det.
<link rel="stylesheet" type="text/css" href="style.css">
<?php
require ("header.php");
include ("functions.php");
$mindrop = $_GET["mindrop"];
$i=1;
$customerData = getCustomerData($mindrop);
foreach ($customerData as $customer) {
if($i==1) {
echo "<br>";
echo "<table class=\"noColor\">";
echo "<td><b> Customer:</b></td><td><input type = \text\" value =\" " .$customer['customer']. "\"></td><tr>";
echo "<td><b>Address:</b></td><td><input type = \text\" value =\" " .$customer['address']. "\"></td><tr>";
echo "<td><b>Zipcode:</b></td><td><input type = \text\" value =\" " .$customer['zipcode']. "\"></td><tr>";
echo "<td><b>City:</b></td><td><input type = \text\" value =\" " .$customer['city']. "\"></td><tr>";
echo "<td><b>Phone:</b></td><td><input type = \text\" value =\" " .$customer['phone']. "\"></td><tr";
$customerId=$customer['id'];
$customerName=$customer['customer'];
echo "</table>";
}
}
echo "<html>
<body>
<table border=\"1\">
<tr>
<tr> ";
echo "<td colspan = \"6\"><b>Contact persons</b></td>
<tr><td><b>Firsname</b></td>
<td><b>Lastname</b></td>
<td><b>Phone</b></td>
<td><b>Mobil Phone</b></td>
<td><b>Email</b></td>";
$result=getContactData($mindrop,1);
if (isset($result)) {
foreach ($result as $value) {
echo "<tr>";
echo "<td><input type=\"text\" value= \"".$value['firstName'] . "\"</td>";
echo "<td><input type=\"text\" value= \"".$value['lastName'] . "\"</td>";
echo "<td><input type=\"text\" value= \"".$value['phone'] . "\"</td>";
echo "<td><input type=\"text\" value= \"".$value['mobilPhone'] . "\"</td>";
//echo "<td><input type=\"text\" value= \"".$value['address'] . "\"</td>";
echo "<td><input type=\"text\" value= \"".$value['emailAddress'] . "\"</td>";
$i=$i+1;
}
}
echo "</table>";
echo "<table>";
echo "<form action=\"add_contact.php\" method=POST>";
echo "<td><input type=\"submit\" value =\" Add contact\"></td>";
echo "<input type = \"hidden\" name = \"custId\" value=$customerId>";
echo "</form>";
echo "<form action=\"show_reports.php\" method=POST>";
echo "<td><input type=\"submit\" value =\" Show support reports\"></td>";
echo "<input type = \"hidden\" name = \"custId\" value=$customerId>";
echo "<input type = \"hidden\" name = \"customerName\" value=\"$customerName\">";
echo "</form>";
echo "<form action=\"add_report.php\" method=POST>";
echo "<td><input type=\"submit\" value =\" Add support report\"></td>";
echo "<input type = \"hidden\" name = \"custId\" value=$customerId>";
echo "</form>";
// HER ER MIN UPDATE KNAP, JEG VILLE GERNE KALDE EN FUNC+TION MED VARIABLER FRA DE FORSKELLIGE TEXTBOXE
echo "<form action=\"$PHP_SELF\" method=POST>";
echo "<td><input type=\"submit\" value =\" Update customer\"></td>";
echo "<input type = \"hidden\" name = \"mindrop\" value=$customerId>";
echo "<input type = \"hidden\" name = \"check\" value=1>";
echo "</table>";
echo "</form>";
echo "</body>
</html>";
?>
Håber der er et par hajer der kan gennemskue hvad det er jeg vil :-)
