ricky spires Posted December 16, 2011 Share Posted December 16, 2011 hello why does my div move when i use a foreach loop ? if i use the code below i get the following i added a border style to the div so i can see that some are in and some are out: result 1 = not in a div result 2 = in a div result 3 = in a div etc then on the end i get a div with no result in it function name(){ echo' <div id="divName">'; $a = Class::find_all(); foreach ($a as $ab){ $name = $ab->name; $dest = $ab->destination; <ul> <li><a href="index.php?pageID='.$dest.'">'.$name.'</a></li> </ul>'; } echo'</div>'; } thanks rick Link to comment https://forums.phpfreaks.com/topic/253318-why-does-my-div-move-when-i-use-a-foreach-loop/ Share on other sites More sharing options...
Ivan Ivković Posted December 20, 2011 Share Posted December 20, 2011 Maybe you're using position: relative; left: (number)px; ? I know that happened to me when I used position: relative while looping divs. If you are, then try not to position those divs by relative or absolute position, but by static. If that was not the problem, then I don't know what the problem is. Maybe post the full code? Link to comment https://forums.phpfreaks.com/topic/253318-why-does-my-div-move-when-i-use-a-foreach-loop/#findComment-1299582 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.