Advertisement

04.19.2008 at 01:13PM PDT, ID: 23336986
[x]
Attachment Details

display images from directory in PHP loop

Asked by satmanuk in PHP Scripting Language

hi all,


i have a dynamic form where i am trying to show images from a directory in the last column of my table.

My table is dynamic because it has as many records as there are images within a chosen directory.

Something i want to add is showing each image in the last column of the table.

If you look at my code in the loop you will see i am echo'ing a fixed image at the moment. So naturally this same image is displayed on each row.

This image needs to be different on each row and in total all images in the chosen folder($dir) will be listed.

Hope im making senseStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
<?php
 
// declare what url to look in and count each file within that directory
$dir = "images/temp/member/";
$count = count(glob($dir . "*"));
 
 
// test if count has found the files in the temp image dir.
echo "count is";
echo $count;
 
 
// Open the folder for display
$dir_handle = @opendir($dir) or die("Unable to open $dir");
 
 
 
// asign the amount of files in the temp dir above to the variable $nFish
$nFish = $count;
 
echo "<form id=\"form1\" name=\"form1\" method=\"post\" action=\"array3.php\">\n";
echo "  <table width=\"600\" border=\"0\">\n";
echo "    <tr>\n";
echo "      <td><p>Amount of Fish (" . $nFish . ")</p>\n";
echo "      <p>&nbsp; </p></td>\n";
echo "      <td>fish_type</td>\n";
echo "      <td>bait</td>\n";
echo "      <td>notes</td>\n";
echo "      <td>Date</td>\n";
echo "      <td>Image Preview</td>\n";
echo "    </tr>\n";
 
 
 
for ($i = 1; $i <= $nFish; $i++) {
  echo "    <tr>\n";
  echo "      <td><div align=\"center\">" . $i . "</div></td>\n";
  echo "      <td><input name=\"fish_type_$i\" type=\"text\" id=\"fish_type_$i\" /></td>\n";
  echo "      <td><input name=\"bait_$i\" type=\"text\" id=\"bait_$i\" /></td>\n";
  echo "      <td><input name=\"notes_$i\" type=\"text\" id=\"notes_$i\" /></td>\n";
  echo "	  <td><input type=\"text\" id=\"date$i\" name=\"date$i\" /></td>\n";
  echo "	  <td><button id=\"trigger\">Click here for Calendar</button></td>";
  echo "	  <td><img src=\"images/bart_logo.jpg\" width=\"264\" height=\"102\" /></td><br>";
  echo "    </tr>\n";
?>
<script type="text/javascript">
  Calendar.setup(
    {
      inputField  : "date<?php echo $i; ?>",         // ID of the input field
      ifFormat    : "%Y-%m-%d",    // the date format
      button      : "trigger"       // ID of the button
    }
  );
</script>
 
<?php  
  echo "    </tr>\n";
}
 
echo "    <tr>\n";
echo "      <td colspan=\"4\"><div align=\"center\">\n";
echo "        <input type=\"submit\" name=\"Submit\" value=\"Submit\" />\n";
echo "      </div></td>\n";
echo "    </tr>\n";
echo "  </table>\n";
echo "</form>\n";
 
?>
[+][-]04.19.2008 at 02:13PM PDT, ID: 21393938

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 02:27PM PDT, ID: 21393985

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 02:32PM PDT, ID: 21394003

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 02:44PM PDT, ID: 21394035

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 03:01PM PDT, ID: 21394122

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 03:06PM PDT, ID: 21394140

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 03:10PM PDT, ID: 21394163

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 03:11PM PDT, ID: 21394164

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 03:13PM PDT, ID: 21394177

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 03:25PM PDT, ID: 21394230

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 04:01PM PDT, ID: 21394361

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 04:06PM PDT, ID: 21394371

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 04:11PM PDT, ID: 21394384

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 04:13PM PDT, ID: 21394391

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 04:18PM PDT, ID: 21394410

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 04:26PM PDT, ID: 21394423

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 04:26PM PDT, ID: 21394427

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 04:39PM PDT, ID: 21394453

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 04:41PM PDT, ID: 21394457

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 04:41PM PDT, ID: 21394458

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 04:45PM PDT, ID: 21394468

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.19.2008 at 04:45PM PDT, ID: 21394470

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP Scripting Language
Sign Up Now!
Solution Provided By: slouko
Participating Experts: 1
Solution Grade: A
 
 
[+][-]04.19.2008 at 04:53PM PDT, ID: 21394488

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628