JqxGrid Server Side Editing / Update using PHP and MySQL (columntype:dropdownlist + using createeditor): Difference between revisions
Jump to navigation
Jump to search
Kaplanerkan (talk | contribs) No edit summary |
Kaplanerkan (talk | contribs) |
||
Line 43: | Line 43: | ||
$con = mysql_connect($host,$username,$password) or die(mysql_error()); | $con = mysql_connect($host,$username,$password) or die(mysql_error()); | ||
mysql_query('SET CHARACTER SET utf8'); | mysql_query('SET CHARACTER SET utf8'); | ||
mysql_select_db($databasename) or die(mysql_error()); | mysql_select_db($databasename) or die(mysql_error()); | ||
$query = "Select | |||
$query = "Select * from waren_gruppen;"; | |||
if (isset($_GET['update'])) | if (isset($_GET['update'])) | ||
{ | { | ||
// UPDATE COMMAND in my MySQL | // UPDATE COMMAND in my MySQL | ||
// UPDATE `waren_gruppen` SET Text ="Deneme" where | // UPDATE `waren_gruppen` SET Text ="Deneme" where SpkNummer= 11 | ||
$update_query = "UPDATE kasse_sql.waren_gruppen SET waren_gruppen. | $update_query = "UPDATE kasse_sql.waren_gruppen SET waren_gruppen.SpkNumber='".$_GET['Number']."', | ||
waren_gruppen.Text='".$_GET['Text']."' WHERE waren_gruppen. | waren_gruppen.Text='".$_GET['Text']."', waren_gruppen.ZeitZone='".$_GET['ZeitZone']."' WHERE waren_gruppen.SpkNumber='".$_GET['Number']."'"; | ||
$result = mysql_query($update_query) or die("SQL Error 1: " . mysql_error()); | $result = mysql_query($update_query) or die("SQL Error 1: " . mysql_error()); | ||
echo $result; | echo $result; | ||
Line 62: | Line 63: | ||
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { | while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { | ||
$employees[] = array( | $employees[] = array( | ||
' | 'SpkNumber' => $row['SpkNumber'], | ||
'Text' => $row['Text'] | 'Text' => $row['Text'], | ||
'ZeitZone' => $row['ZeitZone'] | |||
); | ); | ||
} | } |
Revision as of 01:03, 26 December 2014
My target app is, that the customer must choose and define your "ZeitZone" yourself and save automatically the new values in mysql-tables.
My MySQL Sturucture
CREATE TABLE `waren_gruppen` ( `Number` INT(3) NOT NULL, `Text` VARCHAR(50) NULL DEFAULT NULL, `ZeitZone` INT(2) NULL DEFAULT '0', PRIMARY KEY (`Firma`) ) COLLATE='utf8_general_ci' ENGINE=InnoDB ROW_FORMAT=COMPACT;
PHP File Settings
<?php header('Access-Control-Allow-Origin: *'); $host = "localhost"; $databasename = "kasse_sql"; $username ="root"; $password = "MY_MYSQL_PASSWORT"; // If You want, you can send PASS, QUERY as POST and parser later here in this php // $x = $_GET['t']; // $tmp = explode(";",$x); // $password = $tmp[0]; // $query = $tmp[1] ; // $filename = $tmp[2]; $con = mysql_connect($host,$username,$password) or die(mysql_error()); mysql_query('SET CHARACTER SET utf8'); mysql_select_db($databasename) or die(mysql_error()); $query = "Select * from waren_gruppen;"; if (isset($_GET['update'])) { // UPDATE COMMAND in my MySQL // UPDATE `waren_gruppen` SET Text ="Deneme" where SpkNummer= 11 $update_query = "UPDATE kasse_sql.waren_gruppen SET waren_gruppen.SpkNumber='".$_GET['Number']."', waren_gruppen.Text='".$_GET['Text']."', waren_gruppen.ZeitZone='".$_GET['ZeitZone']."' WHERE waren_gruppen.SpkNumber='".$_GET['Number']."'"; $result = mysql_query($update_query) or die("SQL Error 1: " . mysql_error()); echo $result; } else { // SELECT COMMAND $result = mysql_query($query) or die("SQL Error 1: " . mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $employees[] = array( 'SpkNumber' => $row['SpkNumber'], 'Text' => $row['Text'], 'ZeitZone' => $row['ZeitZone'] ); } echo json_encode($employees); }