LANThrax
Username: Password:  
Sign In
Remember me
Sign Up Now
Forgot Password

php help

Last seen 23-Mar-13 14:32:50
Level 1
рядово́й
(Private)
LANThrax Extremist (90 straight daily logins)
9
Log in everyday for 30 consecutive daysLog in everyday for 60 consecutive daysLog in everyday for 90 consecutive daysComplete the sticker albumVote like the majority 25 times since 24-OCT-2011Incorrectly predict the outcome of the voting game 15 times since 24-OCT-2011Vote 50 times since 24-OCT-2011Correctly predict the outcome of the voting game 40 times since 24-OCT-2011Vote against the trend 25 times since 24-OCT-2011

I doing a small website (school assigment) and I need to upload images and then display them using php

The coding needed to upload an image to the server is done, but i now have a problem to display the uploaded images to the website. The available code is not good( it worked perfectly on a friend website ) can some one check the code for me and tell me what wrong? 

Thank you very much 

 

<?php
$count = 1;
                $dir ="uploads";
                $odir = opendir($dir);
echo "<tr>";
 
 
                while ($file = readdir($odir))
 
                 {
if (!is_dir($file))
                echo "<td><a href='".$file."'>" ."<img src='".$odir .$file."' width = 200px height = 200px /></td>";
 
                        if($count > 2)
                    {
                            echo "</tr><tr>";
                            $count= 0;
                    }
                    $count++;
}
                }
            ?> 
1 
Last seen 17-Dec-12 08:35:04
Level 1
Private E1
LANThrax Extremist (90 straight daily logins)
123
Log in everyday for 30 consecutive daysLog in everyday for 60 consecutive daysLog in everyday for 90 consecutive daysVote like the majority 25 times since 24-OCT-2011

<?php
$count = 0;
$dir ="uploads";
$odir = opendir($dir);

echo "<tr>";
 
 
while ($file = readdir($odir))
{
    if (!is_dir($file))
    {
        echo "<td>";
    echo '<a href="' . $file . '">';
    echo '<img src="' . $file . '" width="200" height="200" alt="Picture" />'
    echo '</a>';
        echo "</td>";
 
        if($count > 2)
        {
            echo "</tr><tr>";
            $count = 0;
        }
        $count++;
    }
}
?>

 

Try this code, you made a lot of mistaked in there:

  1. Use single qoute when echoing HTML tags, allows you to unsert double quotes inside single quote echos
  2. with and height in an HTML tag do not take pixel, just number and on top of that you forgot to quote them.
  3. I dont know how exactly your code works but the count variabl at the top should be 0, not 1. I think...
  4. Also do not just copy and paste code... that wrong and has a failure rate of over 9000!

 

Last seen 23-Mar-13 14:32:50
Level 1
рядово́й
(Private)
LANThrax Extremist (90 straight daily logins)
9
Log in everyday for 30 consecutive daysLog in everyday for 60 consecutive daysLog in everyday for 90 consecutive daysComplete the sticker albumVote like the majority 25 times since 24-OCT-2011Incorrectly predict the outcome of the voting game 15 times since 24-OCT-2011Vote 50 times since 24-OCT-2011Correctly predict the outcome of the voting game 40 times since 24-OCT-2011Vote against the trend 25 times since 24-OCT-2011

First of all Thank you very much 

but I still have an error... damn php

This piece of code is showing when I click on the gallery.

 

2) { echo ""; $count = 0; } $count++; } } ?>
 
This is how I implemented the code( ma nafx xjien namel... alija dan ciniz )
 
  <div id = "centrecontent">
  
  <?php
$count = 0;
$dir ="uploads";
$odir = opendir($dir);
echo "<tr>";
 
 
while ($file = readdir($odir))
{
    if (!is_dir($file))
    {
        echo "<td>";
    echo '<a href="' . $file . '">';
    echo '<img src="' . $file . '" width="200" height="200" alt="Picture" />'
    echo '</a>';
        echo "</td>";
 
        if($count > 2)
        {
            echo "</tr><tr>";
            $count = 0;
        }
        $count++;
    }
}
?>

 

Last seen 12-May-13 13:02:29
Level 1
Private E1
LANThrax Extremist (90 straight daily logins)
69
Log in everyday for 30 consecutive daysLog in everyday for 60 consecutive days10 confirmed bug findsLog in everyday for 90 consecutive days

   echo '<img src="' . $file . '" width="200" height="200" alt="Picture" />'

insejt tamel colin wara picture:

   echo '<img src="' . $file . '" width="200" height="200" alt="Picture" />'; 

ridet tigi ek ^ 

 

Last seen 12-May-13 13:02:29
Level 1
Private E1
LANThrax Extremist (90 straight daily logins)
69
Log in everyday for 30 consecutive daysLog in everyday for 60 consecutive days10 confirmed bug findsLog in everyday for 90 consecutive days

BDW, ekk se jkompli jtella images al dejjem qeda bugjata

Last seen 17-Dec-12 08:35:04
Level 1
Private E1
LANThrax Extremist (90 straight daily logins)
123
Log in everyday for 30 consecutive daysLog in everyday for 60 consecutive daysLog in everyday for 90 consecutive daysVote like the majority 25 times since 24-OCT-2011

BDW, ekk se jkompli jtella images al dejjem qeda bugjata

BlacK ScorpioN



best practice is to get the count of all the images you have in the DIR then create an array of the files and traverse the array. While do loop is dangerous in php. the script could run out of exectution time before it finishes

1 


You can only post questions and replies when you are logged in. You can enlist for free by clicking here.
Page generated in 2.059 seconds