$hostname = "localhost";
$database = "hillcrestjewelers";
$username = "hcjewel";
$password = "SPark11ng";
$MYSQL = mysql_connect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database);
$items = array("itemnumber",
"metal",
"type",
"style",
"cstone",
"cshape",
"cclairty",
"ccolor",
"cweight",
"cscert",
"sstone",
"sshape",
"ssshape",
"sclairty",
"scolor",
"sweight",
"misc1",
"misc2",
"misc3",
"chain",
"length",
"width",
"cost",
"retail",
"status",
"memo",
"memo_number",
"memo_status",
"date"
);
$items_dia = array("id",
"shape",
"weight",
"clairty",
"color",
"depth",
"table",
"cert",
"lab",
"mma",
"mmb",
"mmc",
"flu",
"cro_ang",
"pav_ang",
"cro_h",
"pav_d",
"girdle",
"cost",
"price",
"status",
"memo",
"memo_id",
"memo_status"
);
if (isset($_GET[$items[0]]) && $_GET['code'] == 5306712000 && !isset($_GET['oldnumber'])) {
$string = 'INSERT INTO `jewelery` (';
foreach ($items as $items1) {
$string = $string . '`' . $items1 . '`,';
};
$string = substr($string, 0, -1);
$string = $string . ') VALUES (';
reset($items);
foreach ($items as $items2) {
if ($_GET[$items2] == "") {
$string = $string . 'NULL,';
} else {
$string = $string . "'" . $_GET[$items2] . "',";
};
};
$string = substr($string, 0, -1);
$string = $string . ')';
$check = mysql_query($string, $MYSQL);
echo($string);
$codea1 = mysql_error($MYSQL);
$codea2 = mysql_info($MYSQL);
};
if (isset($_GET[$items_dia[8]]) && $_GET['code'] == 5306712000) {
$string = 'INSERT INTO `diamonds` (';
foreach ($items_dia as $items1) {
$string = $string . '`' . $items1 . '`,';
};
$string = substr($string, 0, -1);
$string = $string . ') VALUES (';
reset($items);
foreach ($items_dia as $items2) {
if ($_GET[$items2] == "") {
$string = $string . 'NULL,';
} else {
$string = $string . "'" . $_GET[$items2] . "',";
};
};
$string = substr($string, 0, -1);
$string = $string . ')';
$check = mysql_query($string, $MYSQL);
echo($string);
echo mysql_error($MYSQL);
echo mysql_info($MYSQL);
};
if (isset($_GET[$items[0]]) && $_GET['code'] == 5306712000 && isset($_GET['oldnumber'])) {
$string = 'UPDATE `jewelery` SET ';
foreach ($items as $items1) {
$string = $string . '`' . $items1 . "` = '" . $_GET[$items1] . "',";
};
$string = substr($string, 0, -1);
reset($items);
$string = $string . "WHERE `itemnumber` = '" . $_GET['oldnumber'] . "';";
$check = mysql_query($string, $MYSQL);
// echo($string);
$codeb1 = mysql_error($MYSQL);
$codeb2 = mysql_info($MYSQL);
};
function format_data($data, $title) {
$printout = mysql_fetch_array($data);
echo('
' . $title . '
' . "\n" . '
' . number_format($printout[0]) . '.00' . '
' . "\n\n");
};
if ($_GET['code'] == '5306712000') {
//total inventory
$data = mysql_query("select sum(retail) from jewelery;");
format_data($data, "Database Retail Total");
//current inventory
$data = mysql_query("select sum(retail) from jewelery where `status` != 'sold' and `status` != 'returned' or `status` is null;");
format_data($data, "Current Inventory Retail");
//Ivan Gems
$data = mysql_query("select sum(retail) from jewelery where `memo` = 'IVAN' and `status` != 'sold' and `status` != 'returned';");
format_data($data, "Ivan Gems Retail");
//Northern Mines
$data = mysql_query("select sum(retail) from jewelery where `status` = 'Northern Mines';");
format_data($data, "Northern Mines");
};
?>
' . "\n" . '
' . $title . '
' . "\n" . '
' . "\n" . '
' . "\n");
};
if (isset($_GET['oldnumber']) && !isset($_GET['actionsubmitedit'])) {
$item_data = mysql_fetch_array(mysql_query("SELECT * FROM `jewelery` WHERE `itemnumber` = '" . $_GET['oldnumber'] . "';"));
if (!$item_data['itemnumber'] == "") {
?>
if (isset($_GET[$items[0]]) && $_GET['code'] == 5306712000 && !isset($_GET['oldnumber'])) {
// echo($string);
echo($codea1);
echo($codea2);
};
if (isset($_GET[$items[0]]) && $_GET['code'] == 5306712000 && isset($_GET['oldnumber'])) {
// echo($string);
echo($codeb1);
echo($codeb2);
};
?>