Location: PHPKode > projects > T-77.com Operational Management System > omis/item_update.php
<?php require_once('Connections/t77_connect.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
  $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}

if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE t77_bill_items SET item_name=%s, item_description=%s, item_price=%s, item_order=%s WHERE item_id=%s",
                       GetSQLValueString($HTTP_POST_VARS['item_name'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['item_description'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['item_price'], "double"),
					   GetSQLValueString($HTTP_POST_VARS['item_order'], "int"),
                       GetSQLValueString($HTTP_POST_VARS['item_id'], "int"));

  mysql_select_db($database_t77_connect, $t77_connect);
  $Result1 = mysql_query($updateSQL, $t77_connect) or die(mysql_error());

  $updateGoTo = "close.php?ref=" . $_GET['ref'] . "quer=" . $_GET['quer'];
  if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

$colname_items = "0";
if (isset($_GET['id'])) {
  $colname_items = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_t77_connect, $t77_connect);
$query_items = sprintf("SELECT * FROM t77_bill_items WHERE t77_bill_items.item_id = %s", $colname_items);
$items = mysql_query($query_items, $t77_connect) or die(mysql_error());
$row_items = mysql_fetch_assoc($items);
$totalRows_items = mysql_num_rows($items);
?>
<?php 
// ================================================
// SPAW PHP WYSIWYG editor control
// ================================================
// Control usage demonstration file
// ================================================
// Developed: Alan Mendelevich, hide@address.com
// Copyright: Solmetra (c)2003 All rights reserved.
// ------------------------------------------------
//                                www.solmetra.com
// ================================================
// $Revision: 1.3 $, $Date: 2003/04/29 17:12:04 $
// ================================================

// this part determines the physical root of your website
// it's up to you how to do this
if (!ereg('/$', $HTTP_SERVER_VARS['DOCUMENT_ROOT']))
  $_root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'].'/';
else
  $_root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];

define('DR', $_root);
unset($_root);

// set $spaw_root variable to the physical path were control resides
// don't forget to modify other settings in config/spaw_control.config.php
// namely $spaw_dir and $spaw_base_url most likely require your modification
$spaw_root = $omis_path . 'spaw/';

// include the control file
include $spaw_root.'spaw_control.class.php';

// here we add some styles to styles dropdown
$spaw_dropdown_data['style']['default'] = 'No styles';
$spaw_dropdown_data['style']['style1'] = 'Style no. 1';
$spaw_dropdown_data['style']['style2'] = 'Style no. 2';

?>
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="styles.css" rel="stylesheet" type="text/css" />
<script language=JavaScript src="calculator/calculator.js"></script>
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td height="31"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="20"><img src="images/tabletopstart.gif" width="20" height="31" /></td>
          <td><table width="100%" height="30" border="0" cellpadding="5" cellspacing="0">
              <tr>
                <td><p><strong>Edit item</strong></p>
                </td>
                <td>&nbsp;</td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td>
      <table width="100%" border="0" cellspacing="0" cellpadding="20">
        <tr>
          <td align="left" valign="top"><form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
            <table width="100%" align="center" cellpadding="5" cellspacing="0" class="tableBorder">
              <tr valign="baseline">
                <td width="150" align="right" valign="top" nowrap="nowrap" bgcolor="#eeeeee"><h1>Item
                    name:</h1>
                </td>
                <td bgcolor="#eeeeee"><input type="text" name="item_name" value="<?php echo $row_items['item_name']; ?>" size="45" />
                </td>
              </tr>
              <tr valign="baseline">
                <td width="150" align="right" valign="top" nowrap="nowrap"><h1>Item
                    description:</h1>
                </td>
                <td>
				  <textarea name="item_description" cols="40" rows="10" id="item_description"></textarea>
				  <?php 
				  		//$sw = new SPAW_Wysiwyg('item_description' /*name*/,$row_items['item_description']/*value*/, 'en' /*language*/, 'mini' /*toolbar mode*/, '' /*theme*/, '100%' /*width*/, '300px' /*height*/);
						//$sw->show();
					?>
                </td>
              </tr>
              <tr valign="baseline">
                <td width="150" align="right" valign="top" nowrap="nowrap" bgcolor="#eeeeee"><h1>Item
                    price:</h1>
                </td>
                <td bgcolor="#eeeeee"><input type="text" name="item_price" value="<?php echo $row_items['item_price']; ?>" size="10" />
            &nbsp;&nbsp; 
                  <a href="javascript:TCR.TCRPopup(document.forms['form1'].elements['item_price'])"><img width="15" height="13" border="0" alt="Klik hier om de calculator weer te geven" src="calculator/calc.gif" /></a> </td>
              </tr>
              <tr valign="baseline">
                <td align="right" valign="top" nowrap="nowrap"><h1>Item order:</h1></td>
                <td><input name="item_order" type="text" id="item_order" value="<?php echo $row_items['item_order']; ?>" size="4" maxlength="4" /></td>
              </tr>
              <tr valign="baseline">
                <td width="150" align="right" valign="top" nowrap="nowrap">&nbsp;</td>
                <td><input name="submit" type="submit" value="Update item" />
                </td>
              </tr>
            </table>
            <input type="hidden" name="MM_update" value="form1" />
            <input type="hidden" name="item_id" value="<?php echo $row_items['item_id']; ?>" />
          </form></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($items);
?>
Return current item: T-77.com Operational Management System