Mtruffa
08-18-2012, 03:51 AM
I have PHP page in which it inputs delivery info based on customer. The form goes to the mysql database to get the userid and company name for the form and the user inputs the rest. Each customer has 3 pricing levels based on grade in their user table. What I need to do is assign the price for the pallet based on the userid and the grade chosen in the form. I know I can get the data when I goto the db in the first form line but i can not figure out how to pass the info down after the company (id) is selected. the pallet price is the price I am looking for based on the grade selected in the input above that.
Here is the code for the page
<?php
include 'dbc.php';
page_protect();
if(!checkAdmin()) {
header("Location: login.php");
exit();
}
$page_limit = 10;
// filter GET values
foreach($_GET as $key => $value) {
$get[$key] = filter($value);
}
foreach($_POST as $key => $value) {
$post[$key] = filter($value);
}
$rs_all = mysql_query("select count(*) as total_all from users") or die(mysql_error());
list($all) = mysql_fetch_row($rs_all);
?>
<?php
$sql="SELECT id, user_name, company FROM users WHERE user_name <> 'admin'";
$result=mysql_query($sql) or die(mysql_error());
$options="";
while ($row=mysql_fetch_array($result)) {
$id=$row["id"];
$thing=$row["company"];
$options.="<OPTION VALUE=\"$id\">".$thing.'</option>';
}
?>
<?php
$err = array();
if($_POST['doDeliver'] == 'Enter Del')
{
if(empty($err)) {
$pallets = $_POST['pal_del'];
$price = $_POST['pal_price'];
$total_cost = $pallets*$price;
$sql_insert = "INSERT into `deliveries`
(`id`,`del_date`,`trail_num`,`pal_del`,`pal_grd`,`pal_price`,`debit`)
VALUES
('$_POST[id]','$_POST[del_date]','$_POST[trail_num]','$_POST[pal_del]','$_POST[pal_grd]','$pal_price','$total_cost') ";
mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());
}
}
?>
<html>
<head>
<title>USMI Pallets, Inc. :: Delivery Entry Main Page</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" type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script language="JavaScript" type="text/javascript" src="js/jquery.ui.datepicker.js"></script>
<script language="JavaScript" type="text/javascript" src="js/jquery-ui-1.8.22.custom.min.js">
</script>
<link href="jquery-ui-1.8.22.custom.css" rel="stylesheet" type="text/css">
<script>
$(function() {
$( "#datepicker" ).datepicker({ dateFormat: "yy-dd-mm" });
});
</script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="14%" valign="top"><?php
if (isset($_SESSION['user_id'])) {?>
<div class="myaccount">
<p><strong>Admin Center</strong></p>
<a href="admin.php">Admin Home</a><br>
<a href="pickup_ent.php">Pickups Entry</a><br>
<a href="delivery_ent.php">Delivery Entry</a><br>
<a href="payment_ent.php">Payment Entry</a><br>
<a href="logout.php">Logout </a>
<?php } ?>
</td>
<td width="74%" valign="top" style="padding: 10px;"><h2><font color="#FF0000">Delivery Entry
Page</font></h2>
<p> </p>
<form name "deliveryform" action="delivery_ent.php" method="post">
<table width="80%" border="0" align="center" cellpadding="10" cellspacing="0" style="background-color: #E4F8FA;padding: 2px 5px;border: 1px solid #CAE4FF;" >
<tr>
<td>
Account:
<SELECT NAME=id>
<OPTION VALUE=0>Choose
<?=$options?>
</SELECT> </td>
</tr>
<tr>
<td>Date: <input name="del_date" type="text" id="datepicker" /></td>
</tr>
<tr>
<td>Trailer #:<select name="trail_num" id="trail_num">
<option selected value=""></option>
<option value="1986-1">1986-1</option>
<option value="1986-2">1986-2</option>
<option value="1986-3">1986-3</option>
<option value="1986-4">1986-4</option>
<option value="1986-5">1986-5</option>
<option value="1986-6">1986-6</option>
<option value="1986-7">1986-7</option>
<option value="1986-8">1986-8</option>
<option value="1986-9">1986-9</option>
<option value="1986-10">1986-10</option>
<option value="1986-11">1986-10</option>
<option value="1986-12">1986-12</option>
</select></td>
</tr>
<tr>
<td>Pallets Delivered: <input id="pal_del" name="pal_del" size="8"></td>
</tr>
<tr>
<td>Grade:<select name="pal_grd" id="pal_grd">
<option selected value=""></option>
<option value="A">Garde A</option>
<option value="B">Grade B</option>
<option value="C">Grade C</option>
</select></td>
</tr>
<tr>
<td>Pallet Price: <input id="pal_price" name="pal_price" size="8" ></td>
</tr>
<tr>
<td><input name="doDeliver" type="submit" id="doDeliver" value="Enter Del"></p>
</td>
</tr>
</table>
</form>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p></td>
<td width="12%"> </td>
</tr>
</table>
</body>
</html>
Here is the code for the page
<?php
include 'dbc.php';
page_protect();
if(!checkAdmin()) {
header("Location: login.php");
exit();
}
$page_limit = 10;
// filter GET values
foreach($_GET as $key => $value) {
$get[$key] = filter($value);
}
foreach($_POST as $key => $value) {
$post[$key] = filter($value);
}
$rs_all = mysql_query("select count(*) as total_all from users") or die(mysql_error());
list($all) = mysql_fetch_row($rs_all);
?>
<?php
$sql="SELECT id, user_name, company FROM users WHERE user_name <> 'admin'";
$result=mysql_query($sql) or die(mysql_error());
$options="";
while ($row=mysql_fetch_array($result)) {
$id=$row["id"];
$thing=$row["company"];
$options.="<OPTION VALUE=\"$id\">".$thing.'</option>';
}
?>
<?php
$err = array();
if($_POST['doDeliver'] == 'Enter Del')
{
if(empty($err)) {
$pallets = $_POST['pal_del'];
$price = $_POST['pal_price'];
$total_cost = $pallets*$price;
$sql_insert = "INSERT into `deliveries`
(`id`,`del_date`,`trail_num`,`pal_del`,`pal_grd`,`pal_price`,`debit`)
VALUES
('$_POST[id]','$_POST[del_date]','$_POST[trail_num]','$_POST[pal_del]','$_POST[pal_grd]','$pal_price','$total_cost') ";
mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());
}
}
?>
<html>
<head>
<title>USMI Pallets, Inc. :: Delivery Entry Main Page</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" type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script language="JavaScript" type="text/javascript" src="js/jquery.ui.datepicker.js"></script>
<script language="JavaScript" type="text/javascript" src="js/jquery-ui-1.8.22.custom.min.js">
</script>
<link href="jquery-ui-1.8.22.custom.css" rel="stylesheet" type="text/css">
<script>
$(function() {
$( "#datepicker" ).datepicker({ dateFormat: "yy-dd-mm" });
});
</script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="14%" valign="top"><?php
if (isset($_SESSION['user_id'])) {?>
<div class="myaccount">
<p><strong>Admin Center</strong></p>
<a href="admin.php">Admin Home</a><br>
<a href="pickup_ent.php">Pickups Entry</a><br>
<a href="delivery_ent.php">Delivery Entry</a><br>
<a href="payment_ent.php">Payment Entry</a><br>
<a href="logout.php">Logout </a>
<?php } ?>
</td>
<td width="74%" valign="top" style="padding: 10px;"><h2><font color="#FF0000">Delivery Entry
Page</font></h2>
<p> </p>
<form name "deliveryform" action="delivery_ent.php" method="post">
<table width="80%" border="0" align="center" cellpadding="10" cellspacing="0" style="background-color: #E4F8FA;padding: 2px 5px;border: 1px solid #CAE4FF;" >
<tr>
<td>
Account:
<SELECT NAME=id>
<OPTION VALUE=0>Choose
<?=$options?>
</SELECT> </td>
</tr>
<tr>
<td>Date: <input name="del_date" type="text" id="datepicker" /></td>
</tr>
<tr>
<td>Trailer #:<select name="trail_num" id="trail_num">
<option selected value=""></option>
<option value="1986-1">1986-1</option>
<option value="1986-2">1986-2</option>
<option value="1986-3">1986-3</option>
<option value="1986-4">1986-4</option>
<option value="1986-5">1986-5</option>
<option value="1986-6">1986-6</option>
<option value="1986-7">1986-7</option>
<option value="1986-8">1986-8</option>
<option value="1986-9">1986-9</option>
<option value="1986-10">1986-10</option>
<option value="1986-11">1986-10</option>
<option value="1986-12">1986-12</option>
</select></td>
</tr>
<tr>
<td>Pallets Delivered: <input id="pal_del" name="pal_del" size="8"></td>
</tr>
<tr>
<td>Grade:<select name="pal_grd" id="pal_grd">
<option selected value=""></option>
<option value="A">Garde A</option>
<option value="B">Grade B</option>
<option value="C">Grade C</option>
</select></td>
</tr>
<tr>
<td>Pallet Price: <input id="pal_price" name="pal_price" size="8" ></td>
</tr>
<tr>
<td><input name="doDeliver" type="submit" id="doDeliver" value="Enter Del"></p>
</td>
</tr>
</table>
</form>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p></td>
<td width="12%"> </td>
</tr>
</table>
</body>
</html>