The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Display images on table style using php

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #29938

    I want to show images from folders and subfolders on table style using php( Ex : 4 or 5 images per row) and select button with each image.Also when mouse cursor on image I want to display it enlarge(little big image).I tried with below code but not display images.Can you help me to do above functions correctly? :?:

    my code:
    $query = "SELECT esubid FROM esubcategory where esubname = ‘$cat’";
    $result = mysql_query($query) ;


    while($row = mysql_fetch_assoc($result))

    $hid = $row;

    $entered_username = $hid;

    $images = "estore/".$entered_username;

    # Location of small versions
    $big = "big/"; # Location of big versions (assumed to be a subdir of above)
    $cols = 5; # Number of columns to display

    if ($handle = opendir($images)) {
    while (false !== ($file = readdir($handle))) {
    if ($file != "." && $file != ".." && $file != rtrim($big,"/")) {
    $files[] = $file;

    $colCtr = 0;

    echo ‘<table width="100%" cellspacing="4"><tr>’;

    foreach($files as $file)
    if($colCtr %$cols == 0)

    echo ‘</tr><tr><td></td></tr><tr>’; ?>
    <form action="testcard.html">
    echo ‘<td align="center" class="border"><img src="’ . $images . $file . ‘" />
    <input name="submit" type="submit" class="searchButton" value="Select" />
    </p> </form>


    echo ‘</table>’ . "rn";



    Instead of using foreach I’d rather make the script to write each image in the second while statement. (Line 26)

    When you’re using $file it might be undefined, so you should write it when it should be defined. If that doesn’t work, try to see if $file gets defined at all.

    Also, when you view the page source, what does the <img src=""> say? That can tell you what PHP is defining $file as.


    thanks ur reply dear.but still I am on this problem.Instead of my code anyone have source code to solve my problems? :roll:

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.