Here's the setup. I have 2 pages, the first is test.php and the second it functions.php. test.php is including functions.php.
I created a function in functions.php called date_arrays and have the code to create 3 arrays. 1 for days, 1 for months, 1 for years.
I am trying to call the date_arrays function from test.php and populate drop_down menus for a form. For some reason I don't believe the array is getting returned to the test.php page. If I move the code to create the array from the functions.php page to the test.php page, it all works fine. I know that it is an issue with getting the array from functions.php to test.php.
functions.php
Code:
<?
require('dbconn.php');
function date_arrays($months) {
while ($d < 32) {
$d++;
$days[$d] = $d;
}
$months[1] = 'January';
$months[2] = 'February';
$months[3] = 'March';
$months[4] = 'April';
$months[5] = 'May';
$months[6] = 'June';
$months[7] = 'July';
$months[8] = 'August';
$months[9] = 'September';
$months[10] = 'October';
$months[11] = 'November';
$months[12] = 'December';
$y = 1940;
while ($y < 2006) {
$years[$y] = $y;
$y++;
}
return $months;//, $days, $years;
}
?>
test.php
Code:
<form name="form1" method="post" action="">
<select name="select" size="1">
<option selected>Test 1</option>
<option>Test 2</option>
<option>Test 3</option>
<option>Test 4</option>
</select>
<br><br>
<select name="month" size="1">
<?
$months = array();
date_arrays($months);
foreach ($months as $current_month) {
echo "<option>$current_month</option>";
}
/*$current_month = current($months);
if ($current_month) {
echo "<option>$current_month</option>";
//echo "<option>Test</option>";
}
else {
}*/
?>
</select>
</form>
Any help is greatly appreciated. Also, if the code isn't done right, tell me. I won't mind, I promise.
Last edited by loki_racer; 08-12-2005 at 09:15 AM..
|