- This topic is empty.
-
AuthorPosts
-
August 15, 2010 at 12:10 am #29938
d747
MemberI 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:
<?php
$query = "SELECT esubid FROM esubcategory where esubname = ‘$cat’";
$result = mysql_query($query) ;if($result){
if(mysql_num_rows($result)>0){
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 displayif ($handle = opendir($images)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != rtrim($big,"/")) {
$files[] = $file;
}
}
closedir($handle);
}$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">
<?php
echo ‘<td align="center" class="border"><img src="’ . $images . $file . ‘" />
<p>
<input name="submit" type="submit" class="searchButton" value="Select" />
</p> </form>
</td>’;$colCtr++;
}echo ‘</table>’ . "rn";
}}}?>
August 15, 2010 at 2:57 am #81594Kestral
MemberInstead 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.
August 15, 2010 at 9:10 am #81601d747
Memberthanks ur reply dear.but still I am on this problem.Instead of my code anyone have source code to solve my problems?
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.