[SOLVED] List games diplay in columns

This is a discussion on "[SOLVED] List games diplay in columns" within the PHP Forum section. This forum, and the thread "[SOLVED] List games diplay in columns are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 1st, 2007, 19:25
Junior Member
Join Date: Sep 2007
Location: Romania
Age: 38
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Smile [SOLVED] List games diplay in columns

I have a list of full games code but a want to arrange all of them in 4 or 5 columns.
This is my php. code i use:
Code: Select all
 <?php

  $games = get_games("order=name&sort=name&limitstart=0&limitnum="._sp($themecfg['lista'])."&htmlize=true");

  $num = count($games);

  $i = 0;
  foreach ($games as $game) {
      ++$i;

      
     

      $link = get_game_link("id="._sp($game['id']));

      echo "<a href='".$link."'></a><br />
And here is the test page when i put the games list:
http://www.arcademania.ro/page/25.html
Thanks in advance anyone give me a little help.

  #2 (permalink)  
Old Oct 1st, 2007, 22:09
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: List games diplay in columns

Code: Select all
 <?php

  $games = get_games("order=name&sort=name&limitstart=0&limitnum="._sp($themecfg['lista'])."&htmlize=true");

  $num = count($games);

  $i = 0;
  foreach ($games as $game) {
      ++$i;

      
     

      $link = get_game_link("id="._sp($game['id']));

      echo "<a href='".$link."' style='display:block;width:20%;float: left;'></a><br />
That should work by having 5 in one row.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
  #3 (permalink)  
Old Oct 2nd, 2007, 06:36
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: List games diplay in columns

Okay, I think I misunderstood what you meant before.

You could try something like

PHP: Select all

<?php


  $games 
get_games("order=name&sort=name&limitstart=0&limitnum="._sp($themecfg['lista'])."&htmlize=true");

  
$num count($games);

  
$i 0;
  foreach (
$games as $game) {


      
     

      
$link get_game_link("id="._sp($game['id']));

     echo 
'<div>';

      echo 
'<a href="'.$link.'" style="width:100px;"></a>';

      if (
$i 4)
        echo 
'</div>';

      
$i++;
This will wrap 4 links at a time in a div, the new div will obviosuly start on a new line. By making all the links the same width, they will line up like columns.

Cheers,
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)

Last edited by Rakuli; Oct 2nd, 2007 at 06:41. Reason: typo correction.
  #4 (permalink)  
Old Oct 2nd, 2007, 11:31
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: List games diplay in columns

PHP: Select all

  foreach ($games as $game) { 

     
$link get_game_link("id="._sp($game['id']));

        if (
$i === 0)
        {
              echo 
'<div style="width: 118px;float: left;">';
          }
      

      echo 
'<div><a href="' $link.'">'.$game['name'].'</a><br /></div>';
       
       
$i++;
      if (
$i == 20) {
      echo 
'</div>';
          
$i=0;
       }

     
      
// - ".$game['rating']."
  

This code fixes it so that there will be 20 links per column.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] multiple columns, text floats out of area... Best solution? alfandango Web Page Design 7 Apr 17th, 2008 12:00
[SOLVED] IE6 is not rendering my columns correctly Oak Web Page Design 26 Jan 13th, 2008 22:12
[SOLVED] Insert new row without knowing number of columns?? nate2099 Databases 2 Dec 27th, 2007 03:51
[SOLVED] 3 columns? PicoDeath Web Page Design 31 Dec 8th, 2007 20:33
[SOLVED] Styling more than one list Lchad Web Page Design 7 Nov 2nd, 2007 06:09


All times are GMT. The time now is 20:44.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43