Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
unforseen line break on 1st loop cycle only
Old 05-09-2005, 01:21 PM unforseen line break on 1st loop cycle only
hiptobesquare's Avatar
Extreme Talker

Posts: 186
Location: London UK
Trades: 0
Hi Im having more troubles with my loops. For some reason when using a for loop to display the results of a form the first result automatically puts in 3 line breaks before it where all the rest of the results dont. Anyone had this problem before? it looks something like this in a browser:

Now choose colour for your doors
for system 1 you need 3doors:
Door 1:


door1 options
Door 2: door2 options
Door 3: door3 options

for system 2 you need 2doors
Door 1: door1 options
Door 2: door2 options

(door$ options refers to a drop down menu displaying results from a mysql query)


My code for the page looks like this:
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++)

{
$sysnumber=($i 1);
$_SESSION["apwidth$i"]  =   $_POST["apwidth$i"];
$_SESSION["apheight$i"] =   $_POST["apheight$i"];
$_SESSION[seekassist]="please call ********";
$overlap 30;
$doorsize2pre = (($_SESSION["apwidth$i"] +  $overlap)      / 2);
$doorsize3pre = (($_SESSION["apwidth$i"] + ($overlap 2)) / 3);
$doorsize4pre = (($_SESSION["apwidth$i"] + ($overlap 3)) / 4);
$doorsize5pre = (($_SESSION["apwidth$i"] + ($overlap 4)) / 5);

$doorsize2 sprintf("%.0f",$doorsize2pre);
$doorsize3 sprintf("%.0f",$doorsize3pre);
$doorsize4 sprintf("%.0f",$doorsize4pre);
$doorsize5 sprintf("%.0f",$doorsize5pre);


//echo"bedroom $sysnumber aperture is ".$_SESSION["apwidth$i"]." mm wide x ".$_SESSION["apheight$i"]." mm high<br>"; 

if ($_SESSION["apheight$i"] >= '2481')
   {
   echo 
"<br><Br>The apperture height you entered for system $sysnumber is too large to make with a single pain door, $_SESSION[seekassist]
         and ask about our split panel doors.<br>"
;
   }

elseif (
$_SESSION["apwidth$i"] >= '5001')
   {
   echo 
"<br><Br>The apperture width you entered for system $sysnumber is too large to make with a single length of track, $_SESSION[seekassist]
         and ask about the possibility of using 2 lengths of track.<br>"
;
   }


elseif (
$_SESSION["apwidth$i"] <= '2000')
  {
  
$numdoor='2';
  echo 
"For system $sysnumber you need $numdoor doors $doorsize2 mm wide and ".$_SESSION["apheight$i"]."mm high each.";
  
$_SESSION["doorsize$i"] = "$doorsize2";
  
$_SESSION["numdoor$i"] = "$numdoor";
for (
$d 0$d $numdoor$d++)
    {
    
$doornumber=($d 1);
    
$query="SELECT DISTINCT glass FROM price ORDER by glass";
    
$result=mysql_query($query)
    or die (
"nope"); 
    echo
"
    <br>Door 
$doornumber
    <form action='chosenglass.php'
    method='post'>
    <select name="
."glasssys$idoor$d".">";
    while (
$row mysql_fetch_array($result))
      {
      
extract($row);
      echo
"

      <option value='
$glass'>$glass";
      }
      echo
"
      </select>\n
      "
;
    }
echo
"<br><br>";
  }

elseif (
$_SESSION["apwidth$i"] <= '3000' and $_SESSION["apwidth$i"] >= '2001')
   {
   
$numdoor='3';
   echo 
"For system $sysnumber you need $numdoor doors $doorsize3 mm wide and ".$_SESSION["apheight$i"]."mm high each.";
   
$_SESSION["doorsize$i"] = "$doorsize3";
   
$_SESSION["numdoor$i"] = "$numdoor";
for (
$d 0$d $numdoor$d++)
    {
    
$doornumber=($d 1);
    
$query="SELECT DISTINCT glass FROM price ORDER by glass";
    
$result=mysql_query($query)
    or die (
"nope"); 
    echo
"
    <br>Door 
$doornumber
    <form action='chosenglass.php'
    method='post'>
    <select name="
."glasssys$idoor$d".">";
    while (
$row mysql_fetch_array($result))
      {
      
extract($row);
      echo
"

      <option value='
$glass'>$glass";
      }
      echo
"
      </select>\n
      "
;
    }
echo
"<br><br>";
  }

elseif (
$_SESSION["apwidth$i"] <= '4000' and $_SESSION["apwidth$i"] >= '3001')
   {
   
$numdoor='4';
   echo 
"For system $sysnumber you need $numdoor doors $doorsize4 mm wide and ".$_SESSION["apheight$i"]."mm high each.";
   
$_SESSION["doorsize$i"] = "$doorsize4";
   
$_SESSION["numdoor$i"] = "$numdoor";
for (
$d 0$d $numdoor$d++)
    {
    
$doornumber=($d 1);
    
$query="SELECT DISTINCT glass FROM price ORDER by glass";
    
$result=mysql_query($query)
    or die (
"nope"); 
    echo
"
    <br>Door 
$doornumber
    <form action='chosenglass.php'
    method='post'>
    <select name="
."glasssys$idoor$d".">";
    while (
$row mysql_fetch_array($result))
      {
      
extract($row);
      echo
"

      <option value='
$glass'>$glass";
      }
      echo
"
      </select>\n
      "
;
    }
echo
"<br><br>";
  }

elseif (
$_SESSION["apwidth$i"] <= '5000' and $_SESSION["apwidth$i"] >= '4001')
   {
   
$numdoor='5';
   echo 
"For system $sysnumber you need $numdoor doors $doorsize5 mm wide and ".$_SESSION["apheight$i"]."mm high each.";
   
$_SESSION["doorsize$i"] = "$doorsize5";
   
$_SESSION["numdoor$i"] = "$numdoor";
for (
$d 0$d $numdoor$d++)
    {
    
$doornumber=($d 1);
    
$query="SELECT DISTINCT glass FROM price ORDER by glass";
    
$result=mysql_query($query)
    or die (
"nope"); 
    echo
"
    <br>Door 
$doornumber
    <form action='chosenglass.php'
    method='post'>
    <select name="
."glasssys$idoor$d".">";
    while (
$row mysql_fetch_array($result))
      {
      
extract($row);
      echo
"

      <option value='
$glass'>$glass";
      }
      echo
"
      </select>\n
      "
;
    }
echo
"<br><br>";
  }
}

echo
"<br><br>
    <input type='submit' value='Select'>
    </form>\n
    "
;
?>
</body>
</html>

Last edited by hiptobesquare; 05-09-2005 at 02:42 PM..
hiptobesquare is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to unforseen line break on 1st loop cycle only
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29456 seconds with 12 queries