1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

two coloumn div class with php

Discussion in 'PHP' started by s.jns, Jun 9, 2013.

  1. #1
    Hi Guys,

    I hope i put this in the right place
    I want to show all items in two sections "left" and "right" using div class and php
    so in html view source code become as below

        <div class="col float_left"> <a href="#">left section...</a></div>
        <div class="cleaner"></div>
        <div class="col float_right"> <a href="#">right section...</a></div>
        <div class="cleaner"></div>
    HTML:
    and then i try it as using php code as following
    
        <?php $class = '_left'; ?>
        <div class="col float<?php echo $class ? '' . $class : $class ; ?>"> <a href="#">left section...</a></div>
        <?php $class = ($class == '_right') ? '_left' : '_right' ; ?>
    PHP:
    css code:
    but it doesn't work, please help me :)
     
    s.jns, Jun 9, 2013 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    and what's the problem? coz this code looks good...
     
    EricBruggema, Jun 10, 2013 IP
  3. gvre

    gvre Member

    Messages:
    35
    Likes Received:
    6
    Best Answers:
    3
    Trophy Points:
    33
    #3
    You should remove the first cleaner div and add specific width for each div.
     
    gvre, Jun 10, 2013 IP
    EricBruggema likes this.
  4. s.jns

    s.jns Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #4
    Thanks for your fast reply
    the problem is that php code doesn't print to 2 sections (left & right), but only 1 section (all in left section), and the html source code view as following
    
       <div class="col float_left"> <a href="#">left section...</a></div>
        <div class="cleaner"></div>
    
        <div class="col float_left"> <a href="#">right section...</a></div>
        <div class="cleaner"></div>
    
    HTML:
     
    s.jns, Jun 10, 2013 IP
  5. s.jns

    s.jns Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #5
    thank You..

    even i removed the first cleaner and add specific width for each div it's seem not work too
     
    s.jns, Jun 10, 2013 IP
  6. gvre

    gvre Member

    Messages:
    35
    Likes Received:
    6
    Best Answers:
    3
    Trophy Points:
    33
    #6
    Could you post a screenshot?
     
    gvre, Jun 10, 2013 IP
  7. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #7
    First up, "clearing div" are 1997 style garbage and have no place in a modern page. You should have the parent or the element after handling that for you.

    Second, your use of classes seems presentational in nature, you're not saying what they really are, you're just using classes willy-nilly. Classes like 'left' and 'right' being for the most part garbage that you might as well go back to writing HTML 3.2 if you're doing that.

    Third, I'm not sure I'm following why you are screwing around with an extra variable... since there's no padding you just make them the same class, and set that class to float:left; width:50%;

    In general though I'm getting the feeling we're not seeing enough of what's going on here.
     
    deathshadow, Jun 10, 2013 IP
  8. s.jns

    s.jns Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #8
    Hi gvre,
    I have not screen yet, its only for learning, mean i want to show some items in page(s) that will look like, e.g.

    Left Right
    ---------------------
    item1 | item2
    item3 | item4
    item5 | item6
    and etc....

    I have seen as a sample odd and even, that look like similar to odd and even

    any idea...

    @deathshadow
    You right, but that any another idea that may useful to fix it? thank
     
    s.jns, Jun 11, 2013 IP