Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to put in a array and call these repeatedly in a page ?

Status
Not open for further replies.

ulag

Programmer
Sep 4, 2001
23
US
I have pulldown menu, which needs to be called at multiple times in a page:

For example this one

for ($i=2;$i<=91; $i++) {
if((($i+$wday)%7)!=0 && (($i+$wday)%7)!=1) {
$tomorrow = mktime (0,0,0,date(&quot;m&quot;) ,date(&quot;d&quot;)+$i,date(&quot;Y&quot;));
$date4 = date(&quot;F d, Y - l&quot;,$tomorrow);
echo &quot;<option value='$date4'>$date4</option> &quot;;
}
}


How to put them in a array and refer back them by array elements.

Thanks
 
How to put what in the array?
______________________________________________________________________
TANSTAAFL!
 
I want to save/store all the values generated from date function and display it over 12 different locations in a page
 
If the options will not change at all, you could just create a string that has the entire tag and data in it, from &quot;<SELECT....>&quot; to &quot;</SELECT&quot;.

Then where ever you needed it, you could then print the string. That way, you wouldn't have to process the array multiple times.

Something like:

$the_select = '<SELECT name=&quot;my_select_name_here&quot;>';

for ($i=2;$i<=91; $i++)
{
if((($i+$wday)%7)!=0 && (($i+$wday)%7)!=1)
{
$tomorrow = mktime (0,0,0,date(&quot;m&quot;) ,date(&quot;d&quot;)+$i,date(&quot;Y&quot;));
$date4 = date(&quot;F d, Y - l&quot;,$tomorrow);
$the_select .= '<option value=&quot;$date4&quot;>' . $date4 . '</option>';
}
}

$the_select = '</SELECT>';[/code][/tt] ______________________________________________________________________
TANSTAAFL!
 
Correction.

Don't put the &quot;<SELECT>&quot; tag in the string. I forgot that you'll have to have multiple names for the input. ______________________________________________________________________
TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top