View Full Version : positioning divs with transition

01-20-2013, 02:56 PM
I am not to sure if transition is required but what i am trying to do is to echo out the results one on each side. Each div may have a different height depending on the length of the content but as for width they are are 310px inside a 630px container. You can see much more clearly in the attachment (boxes.png) what i am trying to achieve. I dont think it can be done with just the float property. Any help would be great!

01-20-2013, 03:59 PM
No, floats won't work for this.

Assuming you're using PHP, I'd have thought the easiest was would be to populate two variables, say $left and $right, alternately with your results (instead of echoing them), and then echo $left and $right into your html at the appropriate place - this way you've split your content into two columns within your container.

01-21-2013, 04:26 PM
$query = "SELECT quote, author FROM $topic LIMIT $start,$records_per_page";

i am doing that and then to print out into a $left and $right though i am confused. is there anyway to split the results from that query into a odds/even?

01-21-2013, 04:30 PM
actually after some thinking i can get it working if its possible to have an if statement that works over 2 php sections. Ill see if that works and let you know how it goes


if($query = mysql_fetch_row($query) == 'check if its ID is EVEN' {



// else if the ID for that row is ODD
else {


Edited code example to show a bit better what i need. Is it possible?

01-21-2013, 06:59 PM
Something like:

$result = mysql_query($query);
$count=0;//initialise a variable to count the results
while ($item = mysql_fetch_array($result))
$count++;//increment the counter each time
if ($count % 2) $left .= <div class="item">.$item['author'].$item['quote']</div>; //if not exactly divisble by 2 must be odd, so left column
//wrap author and quote in other tags as required....
else $right .= <div class="item">.$item['author'].$item['quote']</div>; //otherwise even, so right column

would work.

01-22-2013, 02:20 AM
$left .= <div class="quotepost"><div class="textdiv"><q class="quotetext">.$row['quote']</q></div><p class="quoteauthor">-.$row['author']</p></div><br/>;

I'm getting unexpected '<' error but all my close tags look fine. can anyone see anything odd?

01-22-2013, 08:37 AM

$left .= '<div class="quotepost"><div class="textdiv"><q class="quotetext">'.$row['quote'].'</q></div><p class="quoteauthor">-'.$row['author'].'</p></div><br/>';

You're missing both quotes around your html and concatenation operators after your variables.