GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 17-Mar-2005, 09:40
rams rams is offline
New Member
 
Join Date: Jan 2005
Posts: 10
rams is on a distinguished road

Default Date Range


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: &nbsp;
<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"];

Last edited by LuciWiz : 17-Mar-2005 at 11:04. Reason: Please insert your PHP code between [php] & [/php] tags
 
 

Recent GIDBlogVista ?Widgets? on Windows XP by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Limit combo box and date time picker choice according to database created in folder shinyhui C++ Forum 0 22-Feb-2005 20:16
Limit combo box and date time picker choice according to database created in folder shinyhui MS Visual C++ / MFC Forum 0 22-Feb-2005 02:13
Apache2 config issues monev Apache Web Server Forum 2 28-Jun-2004 06:19
Can't view pages from another machine on the Intranet aevans Apache Web Server Forum 9 14-May-2004 02:26
join problem zuzupus MySQL / PHP Forum 0 14-Aug-2003 05:11

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 09:34.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.