Hi again.
Im rewriting my php so instead of using 15 pages and a load of if statements it will use about 5 pages of loops within loops. The trouble is i can only make my loops work if they are 1st generation. The code printed below works and gives me $_SESSION[numbed] outputs, but if i remove alll of my // marks which blank the nested loop i only get feedback as if $_SESSION[numbed] were equal to 1. The nested loop itself should return multiple outputs each time it is triggered by surrounding one but it doesn't. Would anyone be able to shed some light??
Thankyou
PHP Code:
<?php
session_start();
echo"
<html>
<head>
</head>
<body>";
$user="root";
$host="localhost";
$password="";
$database="doorstop";
$connection = mysql_connect($host,$user,$password) or die ("couldn't connect to server");
$db = mysql_select_db("doorstop") or die ("coudn't locate the database");
for($i = 0; $i < $_SESSION[numbed]; $i++)
{
$_SESSION["apwidth$i"] = $_POST["apwidth$i"];
$_SESSION["apheight$i"] = $_POST["apheight$i"];
$_SESSION[seekassist]="please call ********";
$overlap = 30;
$doorsize2 = (($_SESSION["apwidth$i"] + $overlap) / 2);
$doorsize3 = (($_SESSION["apwidth$i"] + ($overlap * 2)) / 3);
$doorsize4 = (($_SESSION["apwidth$i"] + ($overlap * 3)) / 4);
$doorsize5 = (($_SESSION["apwidth$i"] + ($overlap * 4)) / 5);
echo" bedroom$i aperture is ".$_SESSION["apwidth$i"]." mm wide x ".$_SESSION["apheight$i"]." mm high<br>";
if ($_SESSION["apwidth$i"] <= '2000')
{
$numdoor='2';
echo "For system$i you need $numdoor doors $doorsize2 mm wide and ".$_SESSION["apheight$i"]."mm high each.<br><br>";
$_SESSION["doorsize$i"] = "$doorsize2";
$_SESSION["numdoor$i"] = "$numdoor";
//******If i un comment the following for statement my loops fail***********
// {
// echo "now choose a glass type for";
// }
// for ($i = 0; $i < $_SESSION["numdoor$i"]; $i++)
// {
// $query="SELECT DISTINCT glass FROM price ORDER by glass";
// $result=mysql_query($query)
// or die ("nope");
// echo"
// Door $i:
// <form action='chosenglass.php'
// method='post'>\n
// <select name="."door1glass$i".">\n";
// while ($row = mysql_fetch_array($result))
// {
// extract($row);
// echo"
// <option value='$glass'>$glass\n";
// }
// echo"
// </select>\n";
// }
}
}
echo"
<input type='submit' value='Select'>
</form>\n";
?>
</body>
</html>
Last edited by hiptobesquare; 05-09-2005 at 07:57 AM..
|