Question

How can I randomly select a img to start display?

Asked by: lapucca

I need to randomly select the 1st picture to start displaying from the file path folder at "C:\Inetpub\wwwroot\ctsi\media\images\homeCycleImages2";.  So, let say randomly, the 3rd file is selected to display as the 1st img then after that, the 4th and 5th and then back to 1, 2 3..  will be cycle through in displaying.  How do I modify the following php code to do this?  thanks.

<?php
	//full error reporting & display
	ini_set('error_reporting',E_ALL);
	ini_set('display_errors',1);
	//end error reporting
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Clinical Translational Science Institute (CTSI) - USC, CHLA, COH</title>
<style type="text/css">
.slideshow { height: 250px; width: 450px; margin: auto }
.slideshow2 { height: 250px; width: 450px; margin: auto }
</style>        
 
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<link rel="stylesheet" href="http://www.labctsi.org/newcss/basic.css" type="text/css" />
<link rel="stylesheet" href="http://www.labctsi.org/newcss/site.css" type="text/css" />
<link rel="stylesheet" href="http://www.labctsi.org/newcss/layout.css" type="text/css" />
 
<!-- Css styles for main menu (Superfish + jQuery) -->
 
<link rel="stylesheet" type="text/css" href="http://www.labctsi.org/newcss/superfish-dropdown.css" media="screen" />
 
<!-- Javascript and initialization of main menu (Superfish) -->
<script type="text/javascript" src="http://www.labctsi.org/js/jquery.js"></script> 
<script type="text/javascript" src="http://www.labctsi.org/js/hoverIntent.js"></script> 
<script type="text/javascript" src="http://www.labctsi.org/js/superfish.js"></script>
<script type="text/javascript" src="http://www.labctsi.org/js/supersubs.js"></script>
<script type="text/javascript" src="http://www.labctsi.org/js/jquery.cycle.all.js"></script>
 
<!-- Initialise main menu (Superfish) -->
<script type="text/javascript"> 
	$(document).ready(function()
	{
				$('.slideshow').cycle({
						fx: 'fade',
						speed: 1000, 
                                                timeout:  2000 
				});
				$('.slideshow2').cycle({
						fx: 'fade',
						speed: 5000
				});
		
		$("ul.sf-menu").supersubs({ 
		minWidth:    8,   // minimum width of sub-menus in em units 
		maxWidth:    25,   // maximum width of sub-menus in em units 
		extraWidth:  0     // extra width can ensure lines don't sometimes turn over 
						   // due to slight rounding differences and font-family 
	}).superfish();
				$('#core_Search').attr('action', 'http://www.labctsi.org/index.php');                   
		}); 
 
</script>
</head>
<body class="homePage">
        <table border="0" width="100%" cellspacing="0" cellpadding="0">
    <tr valign="top">
            <td align="left" bgcolor="#000000"><a href="http://www.usc.edu"><img src="http://www.usc.edu/usc/img/01/usc-name-lightgray-black.gif" alt="University of Southern California" width="255" height="25" border="0"/></a></td>
            <td width="50" rowspan="2" align="left" bgcolor="#990100"><a href="http://www.usc.edu"><img src="http://www.usc.edu/usc/img/01/mono-gold-cardinal-med.gif" alt="" width="65" height="50" border="0" /></a></td>
    </tr>
        <tr valign="top">
 
            <td align="left" bgcolor="#990100"><a href="http://www.labctsi.org/"><img src="http://www.labctsi.org/media/images/title.gif" width="475" height="25" border="0" /></a></td>
    </tr>
</table>
 
        <div id="wrapper">
            <div id="header">
                <a href="http://www.labctsi.org"><img src="http://www.labctsi.org/media/images/logolabctsi.gif"/></a>
                <ul id="utilityLinks">
                <li><a href="http://www.labctsi.org/Membership.aspx/Apply"><img src="http://www.labctsi.org/media/images/ctsimember.png" /></a></li>
                </ul>
            </div>
        	<div id="mainNavigation">
        
        <ul class="sf-menu">
                <li>
                        <a href="http://www.labctsi.org/">Home</a>
                </li>
                <li>
                        <a href="#">Centers</a>
 
                        <ul>
                <li><a href="http://www.labctsi.org/index.php/about_cct/">Community</a></li>
                                <li><a href="http://www.labctsi.org/index.php/about_cetcd/">Education</a></li>
                <li><a href="http://www.labctsi.org/index.php/about_chs/">Human Studies</a></li>
                                <li><a href="http://www.labctsi.org/index.php/cbis/">Informatics</a></li>
                                <li><a href="http://www.labctsi.org/index.php/cst">Scientific Translation</a></li>
 
                        </ul>
                </li>
                <li>
                        <a href="#">Programs</a>
                        <ul>
                <li><a href="http://www.labctsi.org/index.php/about_ethics/">Ethics</a></li>
                                <li><a href="http://www.labctsi.org/index.php/about_rdg/">RDG</a></li>
 
                                <li><a href="http://www.labctsi.org/index.php/about_regulatory/">Regulatory</a></li>
                        </ul>
                </li>
                <li>
                        <a href="#a">Resources</a>
                        <ul>
                                <li><a href="#">Community</a></li>
 
                                <li><a href="#">Education</a></li>
                                <li><a href="http://www.labctsi.org/index.php/resources/core_facilities">Research Cores</a></li>
                        </ul>
                </li>
                <li>
                        <a href="#a">Applications</a>
                        <ul>
 
                                <li><a href="http://www.labctsi.org/index.php/feasibility_application_2009">Feasibility Grant Program 2009</a></li>
                        </ul>
                </li>
        </ul>           
</div>
<br/>
<div id = prototype>    
    <CENTER>
            <table cellspacing="10"><tr><td>    
                <div id="curtain"  class="slideshow">
                        <?php
                        $dir = "C:\Inetpub\wwwroot\ctsi\media\images\homeCycleImages1";
 
                        // Open a known directory, and proceed to read its contents
                        if (is_dir($dir)) {
                                if ($dh = opendir($dir)) {
                                        while (($file = readdir($dh)) !== false) {                      
                                                if ($file != "." && $file != "..") {
                                                      
                                                      echo "<img src='http://www.labctsi.org/media/images/homeCycleImages1/".$file."'  width='450' height='250' />";
                                                }
                                        }
                                        closedir($dh);
                                } else {
									echo "<div>Unable to open dir, check permissions.</div>";
								}
                        } else {
							echo "<div>Dir does not exist.</div>";
						}
                        ?>
                </div>
     </td><td>
                <div id="fade"  class="slideshow2">
                        <?php
                        $dir = "C:\Inetpub\wwwroot\ctsi\media\images\homeCycleImages2";
 
                        // Open a known directory, and proceed to read its contents
                        if (is_dir($dir)) {
                                if ($dh = opendir($dir)) {
                                        while (($file = readdir($dh)) !== false) {                      
                                                if ($file != "." && $file != "..") {
                                                      
                                                      echo "<img src='http://www.labctsi.org/media/images/homeCycleImages2/".$file."'  width='450' height='250' />";
                                                }
                                        }
                                        closedir($dh);
                                } else {
									echo "<div>Unable to open dir, check permissions.</div>";
								}
                        } else {
							echo "<div>Dir does not exist.</div>";
						}
                        ?>
                </div>
        </td></tr>      
        </table>
   </CENTER>
</div>
        
 
 
                <br class="clear" />
                <div id="mainContent">
                        <div id="secondaryNavigationColumn">
                            <ul>
                    <li><a href="http://www.labctsi.org/index.php/feasibility_grant_program_2009">Pilot Grant Program 2009 - Announcement</a></li>
                                <li><a href="http://www.labctsi.org/index.php/feasibility_application_2009">Pilot Grant Program 2009 - Applications</a></li>
 
                                </ul>
                        </div>
                        <div id="informationColumn">
                                <p>The NIH has created a national consortium that will transform how clinical and translational research is conducted, ultimately enabling researchers to provide new treatments more efficiently and quickly to patients. Led by NCRR, this new consortium, funded through Clinical and Translational Science Awards (CTSAs), begins with <a href="http://www.ncrr.nih.gov/clinical_research_resources/clinical_and_translational_science_awards/consortium_directory/index.asp">several Academic Health Centers</a> (AHCs) located throughout the nation. Additional AHCs are receiving planning grants to help them prepare applications to join the consortium.</p>
                                <p>When fully implemented in 2012, about 60 institutions will be linked together to energize the discipline of clinical and translational science. The new program draws on NIH's earlier initiatives to re-engineer the clinical research enterprise, one of the key objectives of the NIH Roadmap for medical research.</p>
                                <p>The <a href="http://www.nih.gov/news/pr/oct2006/ncrr-03.htm">NIH News Release</a> and the CTSA Questions and Answers offer additional information on the consortium. CTSA Grant Awardees have agreed to post part of their <a href="https://www.ctnbestpractices.org/networks/nih-ctsa-awardees/">applications</a> for public viewing.</p>
 
                        </div>
                        <div id="newsAndEventsColumn">
                                <h1 id="newsHeading">Recent News</h1>
                                <ul>
                                  <li><span class="date">June 15, 2009</span><br/><a href="http://www.labctsi.org/site/news/webinar_course_on_researcher_commercialization/">Webinar Course on Researcher Commercialization</a></li>
                                  <li><span class="date">February 04, 2009</span><br/><a href="http://www.labctsi.org/site/news/new_la_basin_ctsi_initiative/">New Los Angeles Basin CTSI Initiative</a></li>
                                  <li><span class="date">February 03, 2009</span><br/><a href="http://www.labctsi.org/site/news/american_medical_informatics_association_amia/">AMIA Informatics Webinars </a></li>
                                </ul>
                                <h1 id="eventsHeading">Upcoming Events</h1> 
                                <ul>
                                </ul>
                        </div>
                </div>
                <div id="footer">
                	<a href="#">Terms of Use</a> | <a href="https://usc.centraldesktop.com/login" target="_blank">Central Desktop</a> | <a href="http://www.labctsi.org/system" target="_blank">Content Management</a> | <a href="http://mail.labctsi.org" target="_blank">Email</a> | <a href="http://calendar.labctsi.org" target="_blank">Calendar</a> | <a href="#" target="_blank">Videos</a>
                </div>
        </div>
</body>
</html>
                                  
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:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-11-05 at 14:14:54ID24876320
Topics

PHP Scripting Language

,

Hypertext Markup Language (HTML)

Participating Experts
1
Points
500
Comments
7

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. How to randomly select from a database or read from a file …
    I'm not sure how difficult this question will be so here goes: I have a website that i display galleries of pictures that i display in a PHP page that read's the information from files (currently until i get a mysql database setup) and what i want to do is have the gallery pa...
  2. Randomly reordering links inside a table
    Hi There, Right - at the moment I've got my site randomly displaying 6 tables from a possible 17 which is great: http://www.stylefrogcreative.com/build/randomtables.htm Each table contains 5 links (see example). What I'd love to do is to randomly order these within each ta...
  3. How can I control an IMG to be on top of another IMG?
    Hi, I have 2 IMGs: one with dynsrc tag and another with src tag. How do i write the HTML code so that the <IMG src> will be on top of <IMG dynsrc>? I've used z-index of style tag but the <MG dynsrc always stay on top.

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: lapuccaPosted on 2009-11-05 at 16:15:59ID: 25755584

I have modified code to use an array to store the image file path/name then echo it out.  However, something is wrong because now my web page is blank.  I turned on the Firebug but not getting any error or warning.  Appreciate any help to continue here.  thanks.

            <table cellspacing="10"><tr><td>    
                <div id="curtain"  class="slideshow">
                        <?php
                        $dir = "C:\Inetpub\wwwroot\ctsi\media\images\homeCycleImages1";
			`			$imgCounter = 0;
                        // Open a known directory, and proceed to read its contents
                        if (is_dir($dir)) {
                                if ($dh = opendir($dir)) {
                                        while (($file = readdir($dh)) !== false) {                      
                                                if ($file != "." && $file != "..") {
                                                      
                                                      $imgArray[$imgCounter] = "<img src='http://www.labctsi.org/media/images/homeCycleImages1/".$file."'  width='450' height='250' />";
													  $imgCounter++;
                                                }
                                        }
                                        closedir($dh);
                                } else {
									echo "<div>Unable to open dir, check permissions.</div>";
								}
                        } else {
							echo "<div>Dir does not exist.</div>";
						}
						
						$1stIamgeindex = $rand(0, $imgCounter-1);
						for ($i = $1stIamgeindex; $i < $imgCounter; $i++) {
							echo $imgArray[$imgCounter];
						}
						for ($i = 0; $i < $1stIamgeindex; $i++) {
							echo $imgArray[$imgCounter];
						}
						
                        ?>
                </div>

                                              
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:

Select allOpen in new window

 

by: lapuccaPosted on 2009-11-05 at 16:16:00ID: 25755585

I have modified code to use an array to store the image file path/name then echo it out.  However, something is wrong because now my web page is blank.  I turned on the Firebug but not getting any error or warning.  Appreciate any help to continue here.  thanks.

            <table cellspacing="10"><tr><td>    
                <div id="curtain"  class="slideshow">
                        <?php
                        $dir = "C:\Inetpub\wwwroot\ctsi\media\images\homeCycleImages1";
			`			$imgCounter = 0;
                        // Open a known directory, and proceed to read its contents
                        if (is_dir($dir)) {
                                if ($dh = opendir($dir)) {
                                        while (($file = readdir($dh)) !== false) {                      
                                                if ($file != "." && $file != "..") {
                                                      
                                                      $imgArray[$imgCounter] = "<img src='http://www.labctsi.org/media/images/homeCycleImages1/".$file."'  width='450' height='250' />";
													  $imgCounter++;
                                                }
                                        }
                                        closedir($dh);
                                } else {
									echo "<div>Unable to open dir, check permissions.</div>";
								}
                        } else {
							echo "<div>Dir does not exist.</div>";
						}
						
						$1stIamgeindex = $rand(0, $imgCounter-1);
						for ($i = $1stIamgeindex; $i < $imgCounter; $i++) {
							echo $imgArray[$imgCounter];
						}
						for ($i = 0; $i < $1stIamgeindex; $i++) {
							echo $imgArray[$imgCounter];
						}
						
                        ?>
                </div>

                                              
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:

Select allOpen in new window

 

by: yauhingPosted on 2009-11-05 at 19:09:04ID: 25756318

I did't check the code yet. But I found be error:

1) Please use "/" instead of "\" in the path
2) variable cannot start with number, change $1stIamgeindex to $firstImageindex
3) some logic error, show images should only when the images can be found

Please try my example, and see it still had error or not.

  <table cellspacing="10"><tr><td>    
                <div id="curtain"  class="slideshow">
                        <?php
                        $dir = "C:/Inetpub/wwwroot/ctsi/media/images/homeCycleImages1";
			`			$imgCounter = 0;
						$imgArray = array();
                        // Open a known directory, and proceed to read its contents
                        if (is_dir($dir)) {
                                if ($dh = opendir($dir)) {
                                        while (($file = readdir($dh)) !== false) {                      
                                                if ($file != "." && $file != "..") {
                                                      $imgArray[] = "<img src='http://www.labctsi.org/media/images/homeCycleImages1/".$file."'  width='450' height='250' />";
                                                }
                                        }
                                        closedir($dh);
										
										$imgCounter = sizeof($imgArray);
										$firstIamgeindex = $rand(0, $imgCounter-1);
										for ($i = $firstIamgeindex; $i < $imgCounter; $i++) {
											echo $imgArray[$imgCounter];
										}
										for ($i = 0; $i < $firstIamgeindex; $i++) {
											echo $imgArray[$imgCounter];
										}
                                } else {
									echo "<div>Unable to open dir, check permissions.</div>";
								}
                        } else {
							echo "<div>Dir does not exist.</div>";
						}
                        ?>
                </div>

                                              
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:

Select allOpen in new window

 

by: yauhingPosted on 2009-11-05 at 19:15:19ID: 25756338

I found other error after I test the page, please find the final code sample below:

  <table cellspacing="10"><tr><td>    
                <div id="curtain"  class="slideshow">
                        <?php
						$dir = "C:/Inetpub/wwwroot/ctsi/media/images/homeCycleImages1";
						$imgArray = array();
                        // Open a known directory, and proceed to read its contents
                        if (is_dir($dir)) {
                                if ($dh = opendir($dir)) {
                                        while (($file = readdir($dh)) !== false) {                      
                                                if ($file != "." && $file != "..") {
                                                      $imgArray[] = "<img src='http://www.labctsi.org/media/images/homeCycleImages1/".$file."'  width='450' height='250' />";
                                                }
                                        }
                                        closedir($dh);
										
										$imgCounter = sizeof($imgArray);
										$firstIamgeindex = rand(0, $imgCounter-1);
										for ($i = $firstIamgeindex; $i < $imgCounter; $i++) {
											echo $imgArray[$i];
										}
										for ($i = 0; $i < $firstIamgeindex; $i++) {
											echo $imgArray[$i];
										}
                                } else {
									echo "<div>Unable to open dir, check permissions.</div>";
								}
                        } else {
							echo "<div>Dir does not exist.</div>";
						}
                        ?>
                </div>

                                              
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:

Select allOpen in new window

 

by: lapuccaPosted on 2009-11-06 at 11:33:39ID: 25762325

Hi y, that worked out great.  Thank you.  Just a question, I was using a int counter in the while loop, would that have worked too?  For this line of code, $imgArray[] = "<img src='http://www.labctsi.org/media/images/homeCycleImages2/".$file."'  width='450' height='250' />";
no array index is used.  I guess PHP automatically assigns it from 0?
Thank you.

 

by: yauhingPosted on 2009-11-06 at 12:10:52ID: 25762618

Yes, it should work.

When use $imgArray[] = "some value";

PHP automatically assigns the index from 0.

So remember to init the variable first: $imgArray = array();

 

by: lapuccaPosted on 2009-11-06 at 12:44:16ID: 25762871

Thanks.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...