[PHP-DB] Inserting databasecontent within the same form

2007-09-26 Thread Ruprecht Helms
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:


a:link { color:#FF;
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:#00; font-family:Arial,Helvetica,Verdana,Sans-serif;
font-size:9pt;font-weight:plain;}
h2 { color:#00; font-family:,Helvetica,Verdana,Sans-serif;
font-size:12pt; font-weight:bold;}
h4 { color:#00; font-family:Arial,Helvetica,Verdana,Sans-serif;
font-size:10pt; line-height:12pt; font-weight:bold;}
  


  

  Lange technische Hotline



  

  

  Kunde anlegen


  Kunde bearbeiten


  Kundencalls zeigen
   

  Techniker anlegen


  Techniker bearbeiten


  Ersatzteil anlegen


  Ersatzteil bearbeiten


  Call eröffnen


  Call bearbeiten


  Call
schließen/abrechnen


  Anwendung verlassen

  





  


  

  
Kunde hinzufügen
 

   






  

  Kundennr.
  


  Name
  


  Vorname
  


  Strasse
  


  PLZ

  
Bezeichnung;
$vorwahl = $row_ort->Vorwahl;
}
?>





  Ort
  

   
  Land
  


  Bezeichnung;
?>







  Ansprechpartner
  



  Telefon
  ()  



  Mobil
  


  Fax (nur Rufnummer)
  



  email
  

  



  





 



  








  


  erstellt v.
Ruprecht Helms IT-Service & Softwareentwicklung
Lörrach
  
  

  



Regards,
Ruprecht Helms

Web: http://www.rheyn.de

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Inserting databasecontent within the same form

2007-09-26 Thread Niel Archer
> 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.

I'm having troubling understanding exactly what you want  and I don't
have time to decipher all the code in the hope it will tell me.  My best
guess is you want to use the zipcode from one table, to automatically
add the city name into a form from another table.  If that is so, you
can do it with your query using a join.

SELECT Kunden.*, City.name, City.vorwahl FROM Kunden LEFT JOIN City
USING (zipcode)

This assumes that `zipcode` exists in both tables and is unique in the
"City" table.  You should also process the City.name and City.vorwahl
results for NULL results where `zipcode` does not exist in the "City"
table.

--
Niel Archer

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Inserting databasecontent within the same form

2007-09-27 Thread Ruprecht Helms
Hi Niel,

> SELECT Kunden.*, City.name, City.vorwahl FROM Kunden LEFT JOIN City
> USING (zipcode)

I'm understanding you this is a way for designing the sql-statement.
My customer want that they have inserted the city after typing in the
zipcode in the zipfield. The city should be searched in a database and
inserted in the field city automaticly.

I think the only way is to do that with some ajax-code combined with a
short phpscript.

Actually I have these codes, but the automatic inserting fails, I don't
know why.

-

ajax.js

function Ajax() {
  //Eigenschaften deklarieren und initialisieren
  this.url="";
  this.params="";
  this.method="GET";
  this.onSuccess=null;
  this.onError=function (msg) {
alert(msg)
  }
}

Ajax.prototype.doRequest=function() {
  //Üeberpruefen der Angaben
  if (!this.url) {
this.onError("Es wurde kein URL angegeben. Der Request wird
abgebrochen.");
return false;
  }

  if (!this.method) {
this.method="GET";
  } else {
this.method=this.method.toUpperCase();
  }

  //Zugriff auf Klasse für readyStateHandler ermöglichen
  var _this = this;

  //XMLHttpRequest-Objekt erstellen
  var xmlHttpRequest=getXMLHttpRequest();
  if (!xmlHttpRequest) {
this.onError("Es konnte kein XMLHttpRequest-Objekt erstellt werden.");
return false;
  }

  //Fallunterscheidung nach Übertragungsmethode
  switch (this.method) {
case "GET": xmlHttpRequest.open(this.method,
this.url+"?"+this.params, true);
xmlHttpRequest.onreadystatechange = readyStateHandler;
xmlHttpRequest.send(null);
break;
case "POST": xmlHttpRequest.open(this.method, this.url, true);
 xmlHttpRequest.onreadystatechange = readyStateHandler;
 xmlHttpRequest.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
 xmlHttpRequest.send(this.params);
 break;
  }

  //Private Methode zur Verarbeitung der erhaltenen Daten
  function readyStateHandler() {
if (xmlHttpRequest.readyState < 4) {
  return false;
}
if (xmlHttpRequest.status == 200 || xmlHttpRequest.status==304) {
  if (_this.onSuccess) {
_this.onSuccess(xmlHttpRequest.responseText,
xmlHttpRequest.responseXML);
  }
} else {
  if (_this.onError) {
_this.onError("["+xmlHttpRequest.status+"
"+xmlHttpRequest.statusText+"] Es trat ein Fehler bei der
Datenbertragung auf.");
  }
}
  }
}

//Gibt browserunabhängig ein XMLHttpRequest-Objekt zurück
function getXMLHttpRequest()
{
  if (window.XMLHttpRequest) {
//XMLHttpRequest für Firefox, Opera, Safari, ...
return new XMLHttpRequest();
  } else
  if (window.ActiveXObject) {
try {
  //XMLHTTP (neu) für Internet Explorer
  return new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
  try {
//XMLHTTP (alt) für Internet Explorer
return new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e) {
return null;
  }
}
  }
  return false;
}
-

einfuegen.js

//Instanz der Klasse Ajax erzeugen und mit der Datenübertragung starten
function load()
{

  var plz=document.getElementById("plz").value;

  with (new Ajax()){

url="ort_suchen.php";
method="POST";
params="plz="+plz;
onSuccess=successHandler;
onError=errorHandler;
doRequest();
  }


//Den Text in die Seite einfügen
function successHandler(txt,xml){
  document.getElementById("ort").innerHTML=txt;

}

//Fehler
function errorHandler(msg){
  document.getElementById("text").innerHTML=msg;
}

}

---
ort_suchen.php

Bezeichnung;


  }

echo $ort;

?>

-

in the source-phpscript that do the request I have this

html-header
databaseconnection

...


...

some formcode
...

  PLZ
  


  Ort
  
Ort
...


Regards,
Ruprecht Helms

Web: http://www.rheyn.de

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Inserting databasecontent within the same form

2007-09-27 Thread Niel Archer
Hi Ruprecht,

> > SELECT Kunden.*, City.name, City.vorwahl FROM Kunden LEFT JOIN City
> > USING (zipcode)
> 
> I'm understanding you this is a way for designing the sql-statement.

Yes.

> My customer want that they have inserted the city after typing in the
> zipcode in the zipfield. The city should be searched in a database and
> inserted in the field city automaticly.

> I think the only way is to do that with some ajax-code combined with a
> short phpscript.
> 
> Actually I have these codes, but the automatic inserting fails, I don't
> know why.



Dynamically changing the fields, I'm afraid I can't help. You would be
better trying a list dedicated to ajax.


--
Niel Archer

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php