I’m working on a multi dimensions array but i have a problem
Imagine I have a company that can order some furniture’s Fx 5 chair of different type’s width different standard prices different discount (%) and a price after discount now what
If a company can choose 3 of the 5 chairs to their design range and add each chair thru as checkbox. Then I need to set a discount to that unit and a “final price” and I ned to do it repeatedly, so I could add more chairs later.
My thoughts is something like this
Note that it has to be able to add an empty field in discount if there is no discount and I have to be able to read the values of the given input on of the given unit
I hope that you can help me and thanks for trying Mikkel
<?php
mysql_connect('localhost', 'root', '') or
die("Could not connect: " . mysql_error());
mysql_select_db("hassberg");
?>
<?php
$furniture_id = $_POST['furniture_id'];
$discount = $_POST['discount'];
$netto_price = $_POST['netto_price'];
if (isset($furniture_id)){
$get_info = array($furniture_id, $discount, $netto_price);
$counter = 0;
$counter2 = 0;
foreach($get_info as $shop){
echo "id: " . $shop[$counter][$counter02]." costs ".$shop[0][1]." and you get ".$shop[0][2]."<br />";
$counter++;
if ($counter2 > 3){
$counter2 = 0;
}
}
//OR
$shop2 = array($furniture_id, $discount, $netto_price);
foreach ($row as $rows){
echo "<li><b>The row number $rows</b>";
echo "<ul>";
for ($col = 0; $col < 3; $col++){
echo "<li>".$shop2[$rows][$col]."</li>";
}
echo "</ul>";
echo "</li>";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>tester</title>
</head>
<body>
<form name="create01" method="post" action="<?php echo $PHP_SELF; ?> ">
<?php
$result = @mysql_query("SELECT id
FROM furniture_model;");
if (mysql_num_rows($result) == 0) // Exits if your db table is empty{
echo 'I have no rows to display';
exit;
}
else{
while($row_model = mysql_fetch_assoc($result)){
echo $row_model['id'].
'<input type="checkbox" class="customer_rel_check" name="chosen_model_id[]" value="'.$row_model['id'].'" />
<input type="text" name="discount[]" />%
<input type="text" name="netto_price[]" />€ <br />'; //netto_price will be cumulated of the standard price and the discount
}
}
?>
<input type="submit" name="send" value="create" />
</form>
</body>
</html>