JqxGrid Server Side Editing / Update using PHP and MySQL (columntype:dropdownlist + using createeditor)

From NSB App Studio
Jump to navigation Jump to search

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);
}


Settings in NSB/APPStudio