Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

post links on page in 4 colums

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

post links on page in 4 colums

Postby Godiwa » Mon Jun 16, 2003 3:25 pm

I want to drag out link depending on the date from the DB and have it split ALL the links it find with the date I ask it for in 4 colums on the page, so all I need to drag out from the DB is the link itself and the description, anyone that got the time to help me with this problem please?

I haven't been programming all that long but I want to make my on scripts and well I ask when I need it and I am working on a larger project where that function is just a wee bit of it, anyone that want to help me??

Godiwa
Godiwa
New php-forum User
New php-forum User
 
Posts: 40
Joined: Wed Mar 05, 2003 5:55 am

Postby Redcircle » Mon Jun 16, 2003 4:34 pm

Here is what I use to accomplish what you want.

Code: Select all

   <?php
    $cols = 4;
   $total = mysql_num_rows($result);
   $column_width = round(((1/$cols)*100));
    echo '<table>';
        for($i; $i<$total; $i++)
      {
         $row = mysql_fetch_array($result);

            $current++;
         switch($current)
         {
            case '1':
            echo '<tr><td width="'.$column_width.'">'.$row['data'].'</td>';
            break;
            case $cols:
            echo '<td width="'.$column_width.'">'.$row['data'].'</td></tr>';
            $current = 0;
            break;
            default:
            echo '<td width="'.$column_width.'">'.$row['data'].'</td>';
         }
         
      }
      if($current >=1)
      {
         $current++;
         for($current; $current<=$cols; $current++)
         {
            switch($current)
            {
               case $cols:
               echo '<td></td></tr>';
               break;
               default:
               echo '<td></td>';
            }
         }
      }
   
   echo '</table>';
   ?>
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby Godiwa » Mon Jun 16, 2003 4:47 pm

hmm looks complicated but I will try to build it up so I have the database pull too and so on and then try it out, thanks.

Godiwa
Godiwa
New php-forum User
New php-forum User
 
Posts: 40
Joined: Wed Mar 05, 2003 5:55 am


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot], Google Feedfetcher and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron