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

From NSB App Studio
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
== PHP File Settings ==
== PHP File Settings ==
<pre>
<?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 Firma, Text from waren_gruppen;";
if (isset($_GET['update']))
{
// UPDATE COMMAND in my MySQL
// UPDATE `waren_gruppen` SET Text ="Deneme" where firma = 11
$update_query = "UPDATE kasse_sql.waren_gruppen SET waren_gruppen.Firma='".$_GET['Firma']."',
waren_gruppen.Text='".$_GET['Text']."' WHERE waren_gruppen.Firma='".$_GET['Firma']."'";
$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(
'Firma' => $row['Firma'],
'Text' => $row['Text']
  );
}
echo json_encode($employees);
}
</pre>


== Settings in NSB/APPStudio ==
== Settings in NSB/APPStudio ==

Revision as of 00:41, 26 December 2014

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 Firma, Text from waren_gruppen;";

if (isset($_GET['update']))
{
	// UPDATE COMMAND in my MySQL
	// UPDATE `waren_gruppen` SET Text ="Deneme" where firma = 11

	$update_query = "UPDATE kasse_sql.waren_gruppen SET waren_gruppen.Firma='".$_GET['Firma']."',
	waren_gruppen.Text='".$_GET['Text']."' WHERE waren_gruppen.Firma='".$_GET['Firma']."'";
	 $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(
			'Firma' => $row['Firma'],
			'Text' => $row['Text']
		  );
	}
	 
	echo json_encode($employees);
}


Settings in NSB/APPStudio