Wrox Programmer Forums
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 14th, 2004, 12:16 PM
Registered User
Join Date: Oct 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default gallery problems

ok i have a directory on my site where ppl can upload images to, and i also created a page to display all the uploaded pics. my problem is that i want them to display 4 per row. i tired to get this but it doesn't seem to be working. what do i need to edit

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Directory listing</title>
<style type="text/css" media="screen">
body {
    background-color: #FFF;
    color: #000;
    font-family: Geneva, Arial, sans-serif;
    font-size: 100%;
    line-height: 140%;

img {
border: 0;
height: 100px;
width: 100px;
.grey1 { background-color: #CCC; }
.grey2 { background-color: #DDD; }
<table border="1" cellspacing="0" cellpadding="2">
function usecolor()
    static $colorvalue;

    $trcolor1 = "grey1";
    $trcolor2 = "grey2";

    if($colorvalue == $trcolor1)
        $colorvalue = $trcolor2;
        $colorvalue = $trcolor1;

function test()
    $default_dir = "./";
    if(!($dp = opendir($default_dir))) die("Cannot open $default_dir.");
    while($file = readdir($dp)) $filenames[] = $file;
    echo "<tr><th>Files</th></tr>\n";
    for($i=0; $i < count($filenames); $i++)
        if($filenames[$i] != 'yo1.php' && !preg_match('/^\./',$filenames[$i]) && !is_dir($filenames[$i]))
        // don't show directories, yo1.php and files that start with a dot
        $z = $i % 4;
      if($z == 0){
        echo "<tr><td class=\"" . usecolor() . "\"><a href=\"" . rawurlencode($filenames[$i]) . "\"><img src=\"" . rawurlencode($filenames[$i]) . "\">" . "</td>";
          echo "<tr><td class=\"" . usecolor() . "\"><a href=\"" . rawurlencode($filenames[$i]) . "\"><img src=\"" . rawurlencode($filenames[$i]) . "\">" . "</td></tr>\n";


any help would be great, or if you see any bugs in the code please point it out.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to Create Image Gallery jazzcatone ASP.NET 2.0 Basics 0 September 23rd, 2007 04:06 AM
How to create a video gallery CurvyBabe C# 0 November 15th, 2006 06:17 AM
Image Gallery Help morpheus Javascript How-To 3 February 20th, 2006 07:45 PM
JavaScript Image Gallery welshboy2005 Javascript How-To 0 May 20th, 2005 04:55 AM
photo gallery module eureka VBScript 1 September 3rd, 2004 07:03 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.