Inserting databasecontent within the same form
| From: | Ruprecht Helms | Date: | Wed, 26 Sep 2007 15:32:14 +0000 |
| Subject: | Inserting databasecontent within the same form | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-44059@lists.php.net to get a copy of this message | ||
Hi,
How can I overtake the fieldvalues of city and the first part of the
phonenumber. It should read out the value of the zipfield and check them
with the content of the table "ort". If there is found a recordset with
the same plz the formfields city and the the field "vorwahl" should get
the values of the fields of the recordset.
This is my code:
<style>
a:link { color:#FF0000;
font-family:Arial,Helvetica,Verdana,Sans-serif;font-size:9pt;
font-weight:bold;text-decoration:none;}
a:visited { color:#CC340A;
font-family:Arial,Helvetica,Verdana,Sans-serif;font-size:9pt;
font-weight:bold;text-decoration:none;}
a:active { color:#FFCC00;
font-family:Arial,Helvetica,Verdana,Sans-serif;font-size:9pt;
font-style:italic; font-weight:bold;text-decoration:none;}
a:hover { color:#FF9900;
font-family:Arial,Helvetica,Verdana,Sans-serif;font-size:9pt;
font-weight:bold;text-decoration:none;}
td { color:#000000; font-family:Arial,Helvetica,Verdana,Sans-serif;
font-size:9pt;font-weight:plain;}
h2 { color:#000000; font-family:,Helvetica,Verdana,Sans-serif;
font-size:12pt; font-weight:bold;}
h4 { color:#000000; font-family:Arial,Helvetica,Verdana,Sans-serif;
font-size:10pt; line-height:12pt; font-weight:bold;}
</style>
<script type="text/javascript"><!--
var http = null;
var id = null;
function anfragen()
{
if (window.XMLHttpRequest) {
http = new XMLHttpRequest();
} else if (window.ActiveXObject) {
http = new ActiveXObject("Microsoft.XMLHTTP");
}
if (http != null) {
http.open("GET", "kunde_add_neu.php", true);
//http.onreadystatechange = ausgeben;
http.send(null);
id = window.setTimeout("anfragen()", 5500);
}
}
//--></script>
<table width="100%">
<tbody>
<tr>
<td colspan="3" bgcolor="blue"><div
align="center"><h1
style="color : #ed662c;">Lange technische Hotline</h1></div></td>
</tr>
<tr>
<td width="33%" valign="top" bgcolor="#d3d3d3">
<table>
<tbody>
<TR>
<TD><A href="kunde_add.php">Kunde anlegen</A></TD>
</TR>
<tr>
<td>Kunde bearbeiten</td>
</tr>
<tr>
<td><A href="kunden_suchen.php">Kundencalls zeigen</A></td>
</tr>
<tr>
<td><A href="techniker_add.php">Techniker anlegen</A></td>
</tr>
<tr>
<td><a href="techniker_suchen.php">Techniker
bearbeiten</a></td>
</tr>
<tr>
<td><A href="ersatzteil_add.php">Ersatzteil anlegen</A></td>
</tr>
<tr>
<td><A href="ersatzteil_suchen.php">Ersatzteil
bearbeiten</A></td>
</tr>
<tr>
<td><A href="vorgang_add.php">Call
eröffnen</A></td>
</tr>
<tr>
<td>Call bearbeiten</td>
</tr>
<tr>
<td><a href="vorgang_abschliessen.php">Call
schließen/abrechnen</a></td>
</tr>
<tr>
<td><a href="logout.php">Anwendung verlassen</a></td>
</tr>
</tbody>
</table>
<!-- mysql-real-escapes für Feldinhalte //-->
</td>
<td width="33%">
<table>
<tbody>
<TR>
<TD>
<strong>Kunde hinzufügen</strong>
<p> </p>
<table width="100%">
<TR><TD width="33%"> </TD><td
width="33%"> </td><td
width="33%"> </td></TR></table>
<table>
<tr><TD>
<FORM action="kunde_add1.php" method="POST">
<table>
<tbody>
<tr>
<td>Kundennr.</td>
<td><?
$sql="SELECT * FROM Kunden";
$result=mysql_db_query($datenbank,$sql);
$zahl=mysql_num_rows($result);
echo $zahl;
?></td>
</tr>
<tr>
<td>Name</td>
<td><INPUT type="text" name="name" value="<? echo $name;
?>"></td>
</tr>
<tr>
<td>Vorname</td>
<td><INPUT type="text" name="vorname" value="<? echo
$vorname;
?>"></td>
</tr>
<tr>
<td>Strasse</td>
<td><INPUT type="text" name="strasse" value="<? echo
$strasse;
?>"></td>
</tr>
<tr>
<td>PLZ</td>
<form action="kunde_add.php" method="POST">
<td>
<?
$sql_ort="SELECT * FROM Orte WHERE PLZ='$plz'";
$result_ort=mysql_db_query($datenbank,$sql_ort);
while ($row_ort = mysql_fetch_object($result_ort))
{
$ort = $row_ort->Bezeichnung;
$vorwahl = $row_ort->Vorwahl;
}
?>
<INPUT type="text" name="plz" value="<? echo $plz
?>"></td><td><INPUT
type="submit" name="plz_uebernehmen"
value="übernehmen"></td>
</tr>
<tr>
<td>Ort</td>
<td><INPUT type="text" name="ort" value="<? echo $ort
?>"></td>
</tr>
<tr>
<td>Land</td>
<td>
<SELECT name="land">
<?
$sql="SELECT * FROM Land ORDER BY ID";
$result=mysql_db_query($datenbank,$sql);
while ($row = mysql_fetch_object($result))
{
?>
<option value="<? echo $row->ID; ?>"><? echo $row->Bezeichnung;
?></option>
<?
}
?>
</SELECT>
</td>
</tr>
<tr>
<td>Ansprechpartner</td>
<td><INPUT type="text" name="ansprechpartner" value="<?
echo
$ansprechpartner ?>"></td>
</tr>
<tr>
<tr>
<td>Telefon</td>
<td>(<INPUT type="text"
name="vorwahl">) <INPUT
type="text" name="telefon" value="<? echo $telefon
?>"></td>
</tr>
<tr>
<tr>
<td>Mobil</td>
<td><INPUT type="text" name="mobil" value="<? echo
$mobil ?>"></td>
</tr>
<tr>
<td>Fax (nur Rufnummer)</td>
<td><INPUT type="text" name="fax" value="<? echo $fax
?>"></td>
</tr>
</form>
<tr>
<td>email</td>
<td><INPUT type="text" name="email" value="<? echo $email
?>"></td>
</tr>
</tbody>
</table>
<INPUT type="submit" value="eintragen">
<INPUT type="reset" value="abbrechen">
</FORM>
</TD></tr>
</table>
<table
width="100%"><TR><TD> </td></TR></table>
</td>
</tr>
</tbody>
</table>
</td>
<td width="33%"></td>
</tr>
<tr>
<td>erstellt v.<br>
Ruprecht Helms IT-Service & Softwareentwicklung<br>
Lörrach</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
Regards,
Ruprecht Helms
Web: http://www.rheyn.de