bigheadedd Posted August 25, 2010 Share Posted August 25, 2010 Hi everyone, I had an earlier topic, http://www.phpfreaks.com/forums/index.php/topic,308202.0.html which was asking about how to make a top to bottom, left to right layout. I've figured out what I need to do, but am now stuck on another dilemma. <body onResize="window.location=window.location;" style="overflow-x:hidden"> <?php if (empty($_POST['height'])){ ?> <form name='detect' method='post' action=<?php print $php_SELF;?>> <input type='hidden' name='height' value='height' /> </form> <script language="javascript"><!-- var insideheight = window.innerHeight; window.document.detect.height.value = insideheight; window.document.forms['detect'].submit(); --> </script> <?php } $height = $_POST['height']; echo $height; ?> <div id="header"> </div> <div id="main"> <?php //Initialize variables $col=1; $rows=1; $id=1; $baseheight = 147; $i = 10; $space = $height - $baseheight; //Column Loop while ($col<=4){ echo "<div id=\"container".$col."\">"; //Row Loop if ($height >= 810){ $i=13; } else if ($height >= 759){ $i=12; } else if ($height >= 708){ $i=11; } while ($rows<=$i){ echo "<div class=\"single\">"; echo $id; echo "</div>"; $id++; $rows++; } //Reset row count if ($rows=$i) { $rows=1; $col++; } echo "</div>"; } ?> <script type="text/javascript"> if (window.innerWidth<1100){ document.write('no'); target = document.getElementById('container4'); target.style.display = "none"; } For the moment, the width (container#) is fine. That all works ok. Its the singular rows thats causing me problems. I know what I want to do, and also a hard coded way of doing it, however i'm unsure of how to do it in a better coded way. For example the part if ($height >= 810){ $i=13; } else if ($height >= 759){ $i=12; } else if ($height >= 708){ $i=11; } Works great, except they are hard coded values up until 13. I know that each row needs 51 pixels, and I need to do some sort of loop working out how much ontop of the original 10 rows I need to increment by. I'm not quite sure if i'm making much sense, but any help would be hugely appreciated. Thanks Edd Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted August 26, 2010 Share Posted August 26, 2010 I didn't really follow what your question was exactly. Quote Link to comment Share on other sites More sharing options...
bigheadedd Posted August 26, 2010 Author Share Posted August 26, 2010 Sorry about not explainging it very well. I need to be able to make a loop that increments $i by 1, for every extra 51 pixels the height of the window is over 708. So at the moment its Height = 708; i=10 Height = 759; i=11 Height = 810; i=12 and so on.. I've managed to get it hard coded in with actual numbers, but I'm after more of a dynamic solution. Let me know if this still doesn't make any sense! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.