make two columns

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • antoniosamuels
    New Member
    • Dec 2009
    • 3

    make two columns

    Is there a way to make this a two column display instead of one.
    I want it to go like the following:

    1 | 2
    3 | 4
    5 | 6

    Thanks,

    -----------------------------------------------

    Code:
    <div id="elmodulewide">
    
    <table width="26%" border="0" align="left" cellpadding="5" cellspacing="2" class="eventset" summary="mod_eventlist_wide">
    
    <colgroup>
    			<col width="20%" class="elmodw_col_title" />
    			<col width="20%" class="elmodw_col_category" />
    			<col width="20%" class="elmodw_col_venue" />
    			<col width="15%" class="elmodw_col_eventimage" />
    			<col width="15%" class="elmodw_col_venueimage" />
    	</colgroup>
    
    <?php foreach ($list as $item) :  ?>
    	<tr>
    		<td width="68" valign="top"><span class="event-image-cell">
    		  <?php if ($this->use_modal) : ?>
              <a href="<?php echo $item->eventimageorig; ?>" class="modal" title="<?php echo $item->title; ?>">
              <?php endif; ?>
              <img src="<?php echo $item->eventimage; ?>" alt="<?php echo $item->title; ?>" class="image-preview" />
              <?php if ($item->eventlink) : ?>
              </a>
              <?php endif; ?>
    		</span></td>
          <td width="211" nowrap="wrap"><div align="left"><span class="event-image-cell"><span class="event-title">
            <?php if ($item->eventlink) : ?>
            <a href="<?php echo $item->eventlink; ?>" title="<?php echo $item->title; ?>">
              <?php endif; ?>
              <?php echo $item->title; ?>
              <?php if ($item->eventlink) : ?>
              </a>
            <?php endif; ?>
            </span> <br />
            <span class="date"><?php echo $item->date; ?></span><?php if ($item->time && $this->datemethod == 1) : ?>
            <span class="time"> <?php echo $item->time; ?> </span>
            <?php endif; ?>
          </span></div>
            <div align="left"><span class="venue-title">
              <?php if ($item->venuelink) : ?>
              <a href="<?php echo $item->venuelink; ?>" title="<?php echo $item->venue; ?>">
              <?php endif; ?>
              <?php echo $item->venue; ?><?php if ($item->venuelink) : ?>
              </a>
              <?php endif; ?>
          </span></div></td>
        </tr>
    <?php endforeach; ?>
    </table>
    </div>
    Last edited by Dormilich; Dec 11 '09, 05:17 AM. Reason: Please use [code] tags when posting code
  • kovik
    Recognized Expert Top Contributor
    • Jun 2007
    • 1044

    #2
    ...

    Code:
    $data = array(1, 2, 3, 4, 5, 6);
    $columns = 2;
    $max = sizeof($data);
    
    echo '<table>';
    
    for ($i = 0; $i < $max; ) {
        echo '<tr>';
    
        for ($j = 0; $j < $columns && $i < $max; $j++, $i++) {
            echo '<td>' . $data[$i] . '</td>';
        }
    
        echo '</tr>';
    }
    
    echo '</table>';
    I'd explain it, but it's much easier to write down. Just keep in mind that the syntax of a for loop is "for ( <initialization >; <condition>; <increment> )" and runs the <initialization > once at the start of the loop, and then continuously checks the <condition> to be true and, if it is, runs the body, performs the <increment>, and repeats.

    You are incrementing the main key and the column key at the same time in the inner loop and checking the main key in the inner and outer loop to ensure that you never try to access unavailable array locations.

    Basically, fill the $data array with the input data and set the $columns variable to the amount of columns.


    Untested.

    Comment

    • antoniosamuels
      New Member
      • Dec 2009
      • 3

      #3
      I am still confused. Where do I place this code? or adjust.

      Comment

      • kovik
        Recognized Expert Top Contributor
        • Jun 2007
        • 1044

        #4
        Put it into a random PHP file, look at the output, read the code, understand it, and work with it.

        It's not that hard.

        Comment

        • antoniosamuels
          New Member
          • Dec 2009
          • 3

          #5
          Thank you for your help. I am not a programmer. I am a graphic/web designer and I know how to read some code. But this wasn't written by me. It is a joomla added feature that I install to my website and I would like to make it two columns instead of one. I placed the php in a random file but now I cannot get the events to show up as 1,2,3,4,5,6. This is the website (www.jamonio.com). It is the event section on the front.

          Thanks again,

          Comment

          • kovik
            Recognized Expert Top Contributor
            • Jun 2007
            • 1044

            #6
            Well, if you want anything done that is more than conceptual, then you are looking in the wrong place. We don't work for free.

            If you are looking to pay in order to get this done for you, it can be arranged. ;)

            Comment

            Working...