Posted by Jeremy on 12/26/06 23:35
Hello,
Below is a piece of php code from a site I inherited. It is for displaying
movie clip links on a main page. It works fine but it displays the info
one after another making for a very long page. What I would like to do is
reformat it to a 3 column wide table. I'm kind of new to php - I assume
what I need to do is set some kind of counter starting at a value of 1 at
which point I create the opening <tr> tag. Then I increment the counter by
1 and every time it gets to 3 I make the closing </tr> tag and reset back
to 1? Something like that? I also assume I can put the opening and
closing <td> </td> tags right in the first and last echo statements below
(which I have already done)?
If someone could get me going in the right direction I would appreciate it
very much.
<?
$dir = './video_admin/movies/meta/';
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if($file != '.' && $file != '..')
{
$tmp = array($file);
$tmp = array_merge($tmp,file($dir.$file));
$files[] = $tmp;
}
}
closedir($dh);
}
if(is_array($files))
foreach($files as $movie)
{
echo "<td><div class=\"description\"><h3>{$movie[3]}
</h3>";
$i = 4;
while($movie[$i] != '')
{
$description .= $movie[$i++];
}
echo "<p>{$description}</p>
<a href='/watch.php?m={$movie[0]}'>Watch</a></div>";
$description = '';
echo "<a href='/watch.php?m={$movie[0]}'><img src=
\"./video_admin/movies/thumbs/{$movie[2]}\" /></a>";
echo "<div style=\"clear:both;height:1%\"></div>
</div></td>";
}
?>
Navigation:
[Reply to this message]
|