...

View Full Version : positioning divs with transition



alexkrolla
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!

SB65
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.

alexkrolla
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?

alexkrolla
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


<?php

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

}

?>

<?php
// else if the ID for that row is ODD
else {

}
?>


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

SB65
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.

alexkrolla
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?

SB65
01-22-2013, 08:37 AM
Try:


$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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum