I have the following two files that work to bring up a chart based on the default dates provided. It works, but the user has to click on the chart link, hit a button, then click on the chart link again. I would like to have the chart data display when the user first clicks the chart based on the default date range. Clear as mud? Here's the relevant code for the two files. Any help will be greatly appreciated.
indexleft.php:
PHP Code:
<?php
if (!session_id()) { session_start(); }
session_register("currentStart");
session_register("currentEnd");
print $HTTP_SESSION_VARS[$HTTP_GET_VARS["img"]];
#Get whatever the user has selected
if (isset($HTTP_GET_VARS["start"]))
$SelectedStart = $HTTP_GET_VARS["start"];
else if (isset($HTTP_SESSION_VARS["currentStart"]))
$SelectedStart = $HTTP_SESSION_VARS["currentStart"];
else
$SelectedStart = get_first_datestamp();
if (isset($HTTP_GET_VARS["end"]))
$SelectedEnd = $HTTP_GET_VARS["end"];
else if (isset($HTTP_SESSION_VARS["currentEnd"]))
$SelectedEnd = $HTTP_SESSION_VARS["currentEnd"];
else
$SelectedEnd = get_current_datestamp();
#Save as session variables to be used by other pages
$HTTP_SESSION_VARS["currentStart"] = $GLOBALS["currentStart"] = $SelectedStart;
$HTTP_SESSION_VARS["currentEnd"] = $GLOBALS["currentEnd"] = $SelectedEnd;
?>
<?
function get_current_datestamp(){
//get the current timestamp
$currdate = gmdate("Ymd");
$currday = substr($currdate,6,2);
$currmonth = substr($currdate,4,2);
$curryear = substr($currdate,0,4);
$currdate_stamp = ($curryear . "-" . $currmonth . "-" . $currday);
return $currdate_stamp;
}//end of function get_current_datestamp;
?>
<?
function get_first_datestamp(){
//get the current timestamp
$currdate = gmdate("Ymd");
$currday = substr($currdate,6,2);
$currmonth = substr($currdate,4,2)-1;
$curryear = substr($currdate,0,4);
$currdate_stamp = ($curryear . "-" . $currmonth . "-" . $currday);
return $currdate_stamp;
}//end of function get_first_datestamp;
?>
<form action="<?php echo $HTTP_SESSION_VARS["SCRIPT_NAME"] ?>">
Start:
<input name="start" size=10 value="<?php echo $SelectedStart ?>"><BR>
End:
<input name="end" size=10 value="<?php echo $SelectedEnd ?>">
<input type="submit" value="OK">
</form>
VoltsPerCell.php: (Code for the chart)
session_start(); // This connects to the existing session
if(isset($HTTP_COOKIE_VARS["users_resolution"]))
$screen_res = $HTTP_COOKIE_VARS["users_resolution"];
else //means cookie is not found set it using Javascript
{
?>
<script language="javascript">
<!--
writeCookie();
function writeCookie()
{
var the_cookie = "users_resolution="+ screen.width +"x"+ screen.height;
document.cookie=the_cookie
}
//-->
</script>
<?
}
$Selectedstart = $HTTP_SESSION_VARS["currentStart"];
$Selectedend = $HTTP_SESSION_VARS["currentEnd"];