Best way to code a catalog page

Discussion in 'HTML & Website Design' started by cj1223, Sep 20, 2006.

  1. #1
    Im doing a catalog like site that list a bunch of product images, and i want to line them up 3 a row, but im not sure how to code it. I was going to make a div for both float left, and right but i don't think it will work.what do you think?
     
    cj1223, Sep 20, 2006 IP
  2. intoex

    intoex Peon

    Messages:
    414
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    use tables
    divide your recordset (you got after database selection) into 3 arrays, and then will generate html table use data from first, second, third

    the simpler way is
    
    <table>
    <? for ($i=0; $i<$cnt; $i++) { ?>
    <tr>
      <td><?=$arr1[$i] ?></td>
      <td><?=$arr2[$i] ?></td>
      <td><?=$arr3[$i] ?></td>
    </tr>
    <? } ?>
    </table>
    
    Code (markup):
     
    intoex, Sep 21, 2006 IP
  3. cj1223

    cj1223 Well-Known Member

    Messages:
    287
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #3
    hmmm sounds like it would work(even though i was told to saty away from tables) i dont get the $arr1[$i] ?> or any of that other strange stuff if you could clear that up i would much appreciate it
     
    cj1223, Sep 21, 2006 IP
  4. intoex

    intoex Peon

    Messages:
    414
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    $arrX - it's arrays of prepared list for each columt

    
    $colnum=3;
    
    $arr=array();
    for($i=0; $i<$colnum; $arr[$i++]=array());
    $recordset=array(1,2,3,4,5,6,7,8);
    $cnt=count($recordset);
    
    $limit=1;
    $j=0;
    for($i=0;$i<cnt;$i++) {
      if ($i>$limit*$cnt/$colcnt) {
          $limit++;
          $j++;
      }
      $arr[$limit-1][$j++]=$recordset[$i];
    }
    
    Code (markup):
    after performing you will get $arr[0]=(1,2,3), $arr[1]=(4,5,6) $arr[2]=(7,8)
    Sorry, if some mistakes - didn't checked the code but think, the idea is clear
     
    intoex, Sep 21, 2006 IP