Page 1 of 1
Im Loosing The Plot Plz Plz Help
Posted: Wed Nov 30, 2011 7:07 pm
by ronnimallouk
Im in the middle of making a web site, its an ordering form for certain products where the customer just inputs the amount of qty they are after of each item. there a 2 categories food and merchandise, with the food part i got help from someone on this forum and it worked beautifully i made a few changes to the code but its fine now for merchandise each product has different sizes where each size has its own textbox for customer to input qty of each size they want to order.
heres the food order page
CODE:
Code: Select all
<?php
// Script Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
include "storescripts/connect_to_mysql.php";
// If the form has been posted, process it.
if (!empty($_POST))
{
foreach ($_POST as $k => $v)
{
if ($v > 0)
{
// This is pretty messy, but it prevents having to query the database again
$details = explode('|', $k);
echo "Item: {$details[0]}<br />";
echo "Description: {$details[1]}<br />";
echo "Price: {$details[2]}<br />";
echo "Quantity: {$v}<br /><br />";
}
}
}
// Otherwise, display the order form
else
{
$sql = "SELECT id, product_code, description, units_per_product, unit_price, product_price
FROM food
ORDER BY id ASC";
$products = mysql_query($sql);
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Debug</title>
</head>
<body>
<?php if (isset($products) && $products !== FALSE): ?>
<form id="frmPurchase" action="" method="post">
<table>
<tr>
<th>Code</th>
<th>Description</th>
<th>Units Per</th>
<th>Unit Price</th>
<th>Product Price</th>
<th>Qty</th>
</tr>
<?php while ($row = mysql_fetch_assoc($products)): ?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['description']; ?></td>
<td><?php echo $row['units_per_product']; ?></td>
<td><?php echo $row['unit_price']; ?></td>
<td><?php echo $row['product_price']; ?></td>
<td>
<input type="text" name="<?php echo "{$row['id']}|{$row['description']}|{$row['product_price']}"; ?>" />
</td>
</tr>
<?php endwhile; ?>
<tr>
<td colspan="6">
<input type="submit" value="Place Order" />
</td>
</tr>
</table>
</form>
<?php endif; ?>
</body>
</html>
ORDER PAGE :
Confirm Order Page : This is what comes up when submitted.
Now for the merchandise ordering page
this is what i currently have:
And this is where i need help & ive tried everything i can think of, this is what i want to show when the user submits the order form. i made this page with paint.
The client has been loosing the plot over this and i really need the help
Any input, any help would be GREATLY appreciated.
Thanks In advance.
Re: Im Loosing The Plot Plz Plz Help
Posted: Wed Nov 30, 2011 7:33 pm
by Celauran
How are your input boxes named? Using a naming scheme like productID-size should work easily enough.
Re: Im Loosing The Plot Plz Plz Help
Posted: Wed Nov 30, 2011 8:45 pm
by ronnimallouk
Celauran wrote:How are your input boxes named? Using a naming scheme like productID-size should work easily enough.
Thanks for the reply, i have them named t1 t2 t3 t4 and so on,
can you explain to me what you mean please.
Thanks.
Re: Im Loosing The Plot Plz Plz Help
Posted: Wed Nov 30, 2011 9:06 pm
by Celauran
Let's say the singlet has an ID of T1, then you could use T1-6 for the quantity of singlets in size 6, T1-8 for the quantity of size 8, etc.
Re: Im Loosing The Plot Plz Plz Help
Posted: Wed Nov 30, 2011 9:48 pm
by ronnimallouk
Celauran wrote:Let's say the singlet has an ID of T1, then you could use T1-6 for the quantity of singlets in size 6, T1-8 for the quantity of size 8, etc.
I Think i understand
can you please show me a quick php example of what you mean.
heres my code for the merchandise page this is my first ever time using php so please dont laugh
Code: Select all
<?php
// Script Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php
include "storescripts/connect_to_mysql.php";
$sql = "SELECT * FROM merchandise ORDER BY subcategory ASC";;
$products = mysql_query($sql);
while ($row = mysql_fetch_assoc($products)):
$id = $row["id"];
$product_code = $row["product_code"];
$product_name = $row["product_name"];
$r_r_p = $row["r_r_p"];
$standard_price = $row["standard_price"];
$member_price = $row["member_price"];
$points = $row["points"];
$subcategory = $row["subcategory"];
$details = $row["details"];
$sizes_a = $row["sizes_a"];
$sizes_b = $row["sizes_b"];
$sizes_c = $row["sizes_c"];
$sizes_d = $row["sizes_d"];
$sizes_e = $row["sizes_e"];
$sizes_f = $row["sizes_f"];
$sizes_g = $row["sizes_g"];
$sizes_h = $row["sizes_h"];
$sizes_i = $row["sizes_i"];
$sizes_j = $row["sizes_j"];
$sizes_k = $row["sizes_k"];
$sizes_l = $row["sizes_l"];
$sizes_m = $row["sizes_m"];
$one_size = $row["one_size"];
if (!empty($one_size)){
$one_size = '<font size="1" face="Verdana">QTY</font>';
}
if(empty($sizes_a)){
if(empty($sizes_b)){
if(empty($sizes_c)){
if(empty($sizes_d)){
if(empty($sizes_e)){
if(empty($sizes_f)){
if(empty($sizes_g)){
if(empty($sizes_h)){
if(empty($sizes_i)){
if(empty($sizes_j)){
if(empty($sizes_k)){
if(empty($sizes_l)){
if(empty($sizes_l)){
if(empty($one_size)){
$one_size = '<font size="1" face="Verdana">QTY</font>';
}}}}}}}}}}}}}}
if (empty ($sizes_a)){
$t1 = '';
} else {
$t1 = '<input type="text" name="t_sizes[]" size="1">';
}
if (empty ($sizes_b)){
$t2 = '';
} else {
$t2 = '<input type="text" name="t_sizes[]" size="1">';
}
if (empty ($sizes_c)){
$t3 = '';
} else {
$t3 = '<input type="text" name="t_sizes[]" size="1">';
}
if (empty ($sizes_d)){
$t4 = '';
} else {
$t4 = '<input type="text" name="t_sizes[]" size="1">';
}
if (empty ($sizes_e)){
$t5 = '';
} else {
$t5 = '<input type="text" name="t_sizes[]" size="1">';
}
if (empty ($sizes_f)){
$t6 = '';
} else {
$t6 = '<input type="text" name="t_sizes[]" size="1">';
}
if (empty ($sizes_g)){
$t7 = '';
} else {
$t7 = '<input type="text" name="t_sizes[]" size="1">';
}
if (empty ($sizes_h)){
$t8 = '';
} else {
$t8 = '<input type="text" name="t_sizes[]" size="1">';
}
if (empty ($sizes_i)){
$t9 = '';
} else {
$t9 = '<input type="text" name="t_sizes[]" size="1">';
}
if (empty ($sizes_j)){
$t10 = '';
} else {
$t10 = '<input type="text" name="t_sizes[]" size="1">';
}
if (empty ($sizes_k)){
$t11 = '';
} else {
$t11 = '<input type="text" name="t_sizes[]" size="1">';
}
if (empty ($sizes_l)){
$t12 = '';
} else {
$t12 = '<input type="text" name="t_sizes[]" size="1">';
}
if (empty ($sizes_m)){
$t13 = '';
} else {
$t13 = '<input type="text" name="t_sizes[]" size="1">';
}
if (empty ($one_size)){
$t14 = '';
} else {
$t14 = '<input type="text" name="t_sizes[]" size="1">';
}
?>
<div align="center">
<div align="center">
<table cellpadding="0" cellspacing="0" style="border-left-width: 1px; border-bottom-width: 0px; border-right-width:1px; border-top-width:1px" bordercolor="#000000" width="796" height="102">
<tr>
<td style="border-left-style: solid; border-left-width: 1px; border-top-style: solid; border-top-width: 1px; border-bottom-style: none; border-bottom-width: medium" rowspan="2" width="5" bordercolor="#C0C0C0"> </td>
<td valign="middle" style="border-top-style: solid; border-top-width: 1px" colspan="8" bordercolor="#C0C0C0">
<b>
<font face="Verdana" size="1"> <?php echo $row ['subcategory'];?> </font>
<font face="Verdana" style="font-size: 5pt"> - </font><font face="Verdana" size="1"> </font>
</b><font face="Verdana" size="2"><?php echo $row ['product_name'];?></font></td>
<td valign="bottom" style="border-top-style: solid; border-top-width: 1px" colspan="2" bordercolor="#C0C0C0">
<font face="Verdana" size="1">$<?php echo $row ['r_r_p'];?></font></td>
<td valign="bottom" style="border-top-style: solid; border-top-width: 1px" colspan="3" bordercolor="#C0C0C0">
<font face="Verdana" size="1">$<?php echo $row ['standard_price'];?></font></td>
<td valign="bottom" style="border-top-style: solid; border-top-width: 1px" colspan="5" height="30" bordercolor="#C0C0C0">
<font face="Verdana" size="2" color="#CC0000">$<?php echo $row ['member_price'];?></font></td>
<td valign="middle" style="border-right-style: solid; border-right-width: 1px; border-top-style: solid; border-top-width: 1px; border-bottom-style: none; border-bottom-width: medium" rowspan="2" colspan="2" bordercolor="#C0C0C0">
<p align="center"><font face="Verdana" size="1"><?php echo $row ['product_code'];?><br>
Points : <?php echo $row ['points'];?></font> </td>
</tr>
<tr>
<td width="1" bordercolor="#C0C0C0"></td>
<td valign="middle" style="border-bottom-style: none; border-bottom-width: medium; border-right-style:none; border-right-width:medium" colspan="12" bordercolor="#C0C0C0">
<font face="Verdana" size="1"> Available Sizes :</font></td>
<td valign="middle" style="border-bottom-style: none; border-bottom-width: medium; border-right-style:none; border-right-width:medium" height="22" colspan="5" bordercolor="#C0C0C0">
<p align="center"></td>
</tr>
<tr>
<td style="border-left-style: solid; border-left-width: 1px; " rowspan="2" colspan="2" bordercolor="#C0C0C0"> </td>
<td valign="middle" style="border-bottom-style: solid; border-bottom-width: 1px; border-left-style:solid; border-left-width:1px; border-top-style:solid; border-top-width:1px" align="center" bordercolor="#C0C0C0">
<font face="Verdana" size="1">
</font>
<p align="center">
<form id="frmPurchase" action="review_merchandise_order.php" method="POST">
<font size="1" face="Verdana"><?php echo $row ['sizes_a'];?> <br>
<?php echo $t1;?></font></p>
</td>
<td valign="middle" align="center" style="border-bottom-style: solid; border-bottom-width: 1px; border-left-style:solid; border-left-width:1px; border-top-style:solid; border-top-width:1px" align="center" bordercolor="#C0C0C0">
<font size="1" face="Verdana"><?php echo $row ['sizes_b'];?> <br>
<?php echo $t2;?></font></td>
<td valign="middle" align="center" style="border-left-style: solid; border-left-width: 1px; border-top-style: solid; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px" bordercolor="#C0C0C0">
<font size="1" face="Verdana"><?php echo $row ['sizes_c'];?> <br>
<?php echo $t3;?></font></td>
<td valign="middle" align="center" style="border-left-style: solid; border-left-width: 1px; border-top-style: solid; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px" bordercolor="#C0C0C0">
<font size="1" face="Verdana"><?php echo $row ['sizes_d'];?> <br>
<?php echo $t4;?></font></td>
<td valign="middle" align="center" style="border-left-style: solid; border-left-width: 1px; border-top-style: solid; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px" bordercolor="#C0C0C0">
<font size="1" face="Verdana"><?php echo $row ['sizes_e'];?> <br>
<?php echo $t5;?></font></td>
<td valign="middle" align="center" style="border-left-style: solid; border-left-width: 1px; border-top-style: solid; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px" bordercolor="#C0C0C0">
<font size="1" face="Verdana"><?php echo $row ['sizes_f'];?> <br>
<?php echo $t6;?></font></td>
<td valign="middle" align="center" style="border-left-style: solid; border-left-width: 1px; border-top-style: solid; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px" colspan="2" bordercolor="#C0C0C0">
<font size="1" face="Verdana"><?php echo $row ['sizes_g'];?><br>
<?php echo $t7;?></font></td>
<td valign="middle" align="center" style="border-left-style: solid; border-left-width: 1px; border-top-style: solid; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px" colspan="2" bordercolor="#C0C0C0">
<font size="1" face="Verdana"><?php echo $row ['sizes_h'];?><br>
<?php echo $t8;?></font></td>
<td valign="middle" align="center" style="border-left-style: solid; border-left-width: 1px; border-top-style: solid; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px" bordercolor="#C0C0C0">
<font size="1" face="Verdana"><?php echo $row ['sizes_i'];?><br>
<?php echo $t9;?></font></td>
<td valign="middle" align="center" style="border-left-style: solid; border-left-width: 1px; border-top-style: solid; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px" colspan="2" bordercolor="#C0C0C0">
<font size="1" face="Verdana"><?php echo $row ['sizes_j'];?><br>
<?php echo $t10;?></font></td>
<td valign="middle" align="center" style="border-left-style: solid; border-left-width: 1px; border-top-style: solid; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px" bordercolor="#C0C0C0">
<font size="1" face="Verdana"><?php echo $row ['sizes_k'];?><br>
<?php echo $t11;?></font></td>
<td valign="middle" align="center" style="border-style: solid; border-width: 1px" bordercolor="#C0C0C0">
<font size="1" face="Verdana"><?php echo $row ['sizes_l'];?><br>
<?php echo $t12;?></font></td>
<td valign="middle" align="center" style="border-top-style: solid; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px" bordercolor="#C0C0C0">
<font face="Verdana" size="1"><?php echo $row ['sizes_m'];?><br>
<?php echo $t13;?></font></td>
<td valign="middle" align="center" style="border-style: solid; border-width: 1px" colspan="2" height="44" bordercolor="#C0C0C0">
<font size="1" face="Verdana"><?php echo $one_size;?><br>
<?php echo $t14;?></font></td>
<td valign="middle" align="center" style="border-right-style: solid; border-right-width: 1px; border-bottom-style: none; border-bottom-width: medium" rowspan="2" width="10" bordercolor="#C0C0C0">
<font face="Verdana" size="1"><br>
</font></td>
</tr>
<tr>
<td width="50" bordercolor="#C0C0C0"></td>
<td width="50" bordercolor="#C0C0C0"></td>
<td width="50" bordercolor="#C0C0C0"></td>
<td width="50" bordercolor="#C0C0C0"></td>
<td width="50" bordercolor="#C0C0C0"></td>
<td width="50" bordercolor="#C0C0C0"></td>
<td width="6" bordercolor="#C0C0C0"></td>
<td width="44" bordercolor="#C0C0C0"></td>
<td width="28" bordercolor="#C0C0C0"></td>
<td width="22" bordercolor="#C0C0C0"></td>
<td width="50" bordercolor="#C0C0C0"></td>
<td width="37" bordercolor="#C0C0C0"></td>
<td width="13" bordercolor="#C0C0C0"></td>
<td width="50" bordercolor="#C0C0C0"></td>
<td width="50" bordercolor="#C0C0C0"></td>
<td width="50" bordercolor="#C0C0C0"></td>
<td width="11" bordercolor="#C0C0C0"></td>
<td width="117" height="6" bordercolor="#C0C0C0"></td>
</tr>
</table>
</div>
<div align="center">
<table cellpadding="0" cellspacing="0" border="0" bordercolor="#000000" width="796" height="10">
<tr>
<td valign="top" style="border-top-style: solid; border-top-width: 1px" height="3" bordercolor="#C0C0C0">
<span style="font-size: 1pt">.</span></td>
</tr>
<tr>
<td height="7" width="796" bordercolor="#C0C0C0"></td>
</tr>
</table>
</div>
</div>
<input type="hidden" name="<?php echo $id; ?>" value="i" />
</td>
</tr>
<?php endwhile; ?>
<tr>
<td colspan="6">
<input type="submit" value="Place Order" />
</td>
</tr>
</table>
</form>
</body>
</html>
Re: Im Loosing The Plot Plz Plz Help
Posted: Fri Dec 02, 2011 12:56 am
by ronnimallouk
Celauran wrote:Let's say the singlet has an ID of T1, then you could use T1-6 for the quantity of singlets in size 6, T1-8 for the quantity of size 8, etc.
I knew it was going to be a hard one, oh well, ill try to figure somthing out.
Thanks anyway.
Re: Im Loosing The Plot Plz Plz Help
Posted: Fri Dec 02, 2011 6:15 am
by Celauran
ronnimallouk wrote:I knew it was going to be a hard one
I don't see what's difficult about it. Instead of using t_sizes[] everywhere, use a name that matches the product and size.
Re: Im Loosing The Plot Plz Plz Help
Posted: Fri Dec 02, 2011 7:46 am
by ronnimallouk
Celauran wrote:ronnimallouk wrote:I knew it was going to be a hard one
I don't see what's difficult about it. Instead of using t_sizes[] everywhere, use a name that matches the product and size.
Hey thanks for the reply, can you please show me just a brief example just to get me on the right track,
& i promise ill stop bugging you.
Re: Im Loosing The Plot Plz Plz Help
Posted: Sat Dec 03, 2011 7:02 pm
by internet-solution
Celauran suggested something like this -
Code: Select all
$t1 = '<input type="text" name="'.$product_code.'-a" size="1">'
and so on