Jump to content

why does my div move when i use a foreach loop ?


ricky spires

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.