CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   HTML & CSS (http://www.codingforums.com/forumdisplay.php?f=13)
-   -   positioning divs with transition (http://www.codingforums.com/showthread.php?t=286144)

alexkrolla 01-20-2013 01:56 PM

positioning divs with transition
 
1 Attachment(s)
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 02: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 03:26 PM

Code:

$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 03: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

Code:

<?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 05:59 PM

Something like:

PHP Code:

$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 01:20 AM

Code:

$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 07:37 AM

Try:

PHP Code:

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


All times are GMT +1. The time now is 09:47 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.