3.2.0

INSERT ,DELETE data from a DataBase (MySQL)

I have used the snippets in other threads on this sitefor update data.
I would kindly like now to know whether to cancel and to insert lines or columns
They are three days that I am going crazy.
Help me please.
Thanks in advance for any responses.
CarenZ
July 12,
Help me please!!!!
CarenZ
CarenZ
July 12,
maybe give a bit more infomation I don't understand what you need to know and I am sure others are the same
July 13,
If you are asking how to access mySQL then you are posting your information to the wrong web site. mySQL is a server side program and this grid is a client side grid.
Jim Hunter
July 13,
Hi can anyone plz provide me code for displaying data from database
BDC
January 5,
very insecure example.

URL input => php using MYSQL backend => output CSV format

All you do is send a delete, insert, update URL command like and other simeple web aplication but all you need to do is update your grid after every change with fresh info from the DB.

data2.php
<?php 

function db_connect() { 
  $database_name = 'xxxxxxx'; // Set this to your Database Name 
  $database_username = 'xxxxxxx'; // Set this to your MySQL username 
  $database_password = 'xxxxxxx'; // Set this to your MySQL password 
  $result = mysql_pconnect('localhost',$database_username, $database_password); 
  if (!$result) return false; 
  if (!mysql_select_db($database_name)) return false; 
  return $result; 
} 

$conn = db_connect(); // Connect to database 
$query;
$type = isset($_REQUEST['pr']) ? $_REQUEST['pr'] : '';
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : '';
$fn = isset($_REQUEST['fn']) ? $_REQUEST['fn'] : '';
$ln = isset($_REQUEST['ln']) ? $_REQUEST['ln'] : '';
$ad = isset($_REQUEST['ad']) ? $_REQUEST['ad'] : '';
$ct = isset($_REQUEST['ct']) ? $_REQUEST['ct'] : '';
$st = isset($_REQUEST['st']) ? $_REQUEST['st'] : '';
$zp = isset($_REQUEST['zp']) ? $_REQUEST['zp'] : '';
$cn = isset($_REQUEST['cn']) ? $_REQUEST['cn'] : '';
$ph = isset($_REQUEST['ph']) ? $_REQUEST['ph'] : '';

if ( $type == "Update") {
  $query = "UPDATE GUEST SET "
          . "F_NAME = '" . $fn
          . "', L_NAME = '" . $ln
          . "', STR_ADDRESS = '" . $ad
          . "', CITY = '" . $ct
          . "', STATE = '" . $st
          . "', ZIP = " . $zp
          . ", COUNTRY = '" . $cn
          . "', PHONE_Num = '" . $ph
          . "' WHERE  GUEST_ID = " . $id;
}
if ( $type == "Add") {
  $query = "INSERT INTO GUEST "
          . "(F_NAME, L_NAME, STR_ADDRESS, "
          . "CITY, STATE, ZIP, COUNTRY, PHONE_Num)"
          . " VALUES ("  
          . "'"    . $fn . "', '" . $ln
          . "', '" . $ad . "', '" . $ct
          . "', '" . $st . "', "  . $zp
          . ", '"  . $cn . "', '" . $ph . "')";
}
if ( $type == "Delete") {
  $query = "DELETE FROM GUEST WHERE  GUEST_ID = " . $id;
}
echo $query;
if ($conn && $query != "") { 
  $result = mysql_query($query,$conn);
}
?>


SAMPLE ACTIVE WIDGET BUTTON DELETE RECORD

bobj3.onClick = function(text){		// When Button 3 is clicked
        if(live_button){			// If Button 3 is activated 
          var Da = new Date();
          // Create url to send delete command to data2.php program
      var tmp = "/data2.php?pr=Delete" +
      "&id=" + input1.getControlText() +
                  "&m="  + Da.getTime();	// Done to deal with page cacheing
          output.setControlText(tmp);	// Output URL to Debug text field
          sendRequest(tmp);		// Send URL
          clear_form();			// Clear Member Form Field
          pausecomp(1250);	// Pause program to give database time to update
          load("data.php?t=guest");		// Retrive Reload Members table
        }
};


when the delete button is clicked it will send a delete command to the server to with the unique record ID. It will them clear the record form (something not shown in this example) wait a few second then update the grid with new data.

most of the above funtions are retrive from several past forum postfrom other contributurs all pulled togeather to deal with one problem or another.

Hope this helps you.
David Gutierrez
January 5,

This topic is archived.

See also:


Back to support forum