Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    positioning divs with transition

    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!
    Attached Thumbnails Attached Thumbnails positioning divs with transition-boxes.png  

  • #2
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,949
    Thanks
    9
    Thanked 724 Times in 718 Posts
    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.
    Last edited by SB65; 01-20-2013 at 03:05 PM.
    Use the W3C HTML Validator and CSS Validator to check your code and Firebug to see what css is applied to an element
    Read Steve Krug's book Don't Make Me Think - essential reading on web usability
    I don't recommend much, but I do recommend Clook for UK web hosting

  • #3
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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?

  • #4
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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?
    Last edited by alexkrolla; 01-21-2013 at 03:40 PM.

  • #5
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,949
    Thanks
    9
    Thanked 724 Times in 718 Posts
    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.
    Last edited by SB65; 01-21-2013 at 06:08 PM.
    Use the W3C HTML Validator and CSS Validator to check your code and Firebug to see what css is applied to an element
    Read Steve Krug's book Don't Make Me Think - essential reading on web usability
    I don't recommend much, but I do recommend Clook for UK web hosting

  • Users who have thanked SB65 for this post:

    alexkrolla (01-22-2013)

  • #6
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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?

  • #7
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,949
    Thanks
    9
    Thanked 724 Times in 718 Posts
    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.
    Use the W3C HTML Validator and CSS Validator to check your code and Firebug to see what css is applied to an element
    Read Steve Krug's book Don't Make Me Think - essential reading on web usability
    I don't recommend much, but I do recommend Clook for UK web hosting


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •