I have the following PHP script:
$OperMode = $_POST['oper'];
switch($OperMode) {
/* [...] */
case 'ManAdd':
// get data
$Firma = $_POST['Name'];
$Adresse = $_POST['Address'];
$PLZ = $_POST['PLZ'];
$Ort = $_POST['Ort'];
$TelNr = $_POST['TelNr'];
/* [...] */
// save data to SQL database with adapted strings
$Insert ="INSERT INTO adresse (Nachname, Vorname, Strasse, Hausnummer, Postleitzahl, Ort, Telefonnummer) VALUES('$Nachname', '$Vorname', '$Strasse', '$Hausnummer', '$PLZ', '$Ort', '$TelNr')";
if(mysql_query($Insert)) {
echo "Eintrag erfolgreich."; // Successful
} else {
die("Eintrag nicht erfolgreich!<br>Telefonnummer existiert bereits!"); // Not successful
}
break;
Now I'd like to save selected rows from a jqGrid with the PHP script above. Here is the code of the grid and a custom button:
$("#ResultGrid")
.jqGrid({
colNames:['Firma', 'Adresse', 'Postleitzahl', 'Ort', 'Telefonnummer'],
colModel:[
{name:'Firma', index:'Firma', width:175, searchable:false},
{name:'Adresse', index:'Adresse', width:160, searchable:false},
{name:'Postleitzahl', index:'Postleitzahl', width:100, searchable:false, sorttype:'int'},
{name:'Ort', index:'Ort', width:150, searchable:false},
{name:'Telefonnummer', index:'Telefonnummer', width:160, searchable:false}
],
datatype: "clientSide",
editurl:'Edit.php',
height: 'auto',
loadonce: true,
multiselect: true,
pager:'#ResultPager',
rownum:-1,
})
.navGrid('#ResultPager', {view:false, edit:false, add:false, del:false, search:false, refresh:false} )
.navButtonAdd('#ResultPager', {title:"Adresse ins Addressbuch übernehmen", buttonicon:"ui-icon-disk", caption:"Speichern", onClickButton:function(){
if($("#ResultGrid").getGridParam('selrow') == null || $("#ResultGrid").getGridParam('selrow') == undefined) {
$("#Dialog").html("<p><span class=\"ui-icon ui-icon-info\" style=\"float:left; margin:0 7px 20px 0;\"></span>Bitte eine Adresse auswählen!</p>");
$("#Dialog").dialog("option", "title", "Hinweis:");
$("#Dialog").dialog("open");
} else {
var ID = $("#ResultGrid").getGridParam('selrow');
var AddressRow = $("#ResultGrid").getRowData(ID);
// The data to be stored:
var NameLine = AddressRow.Firma;
var AddressLine = AddressRow.Adresse;
var ZipCode = AddressRow.Postleitzahl;
var City = AddressRow.Ort;
var PhoneNumber = AddressRow.Telefonnummer;
$.ajax({
type: 'POST',
url: 'Edit.php',
dataType: // ???
data: // ???
});
}
}})
I need to post the operation mode "ManAdd" (oper = "ManAdd") and the address to the server. In this case which datatype is needed and how is the data option constructed?