I was used to get variables from input using scripts like this one:
<form method="post" action="<?php echo $PHP_SELF?>">
<?php
include "include/get_root_atfs.inc";
$sql = "SELECT * FROM atproject WHERE atp_id=$atp_id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$atp_id = $myrow["atp_id"];
$atp_at_id = $myrow["atp_at_id"];
$codetargetadr = $myrow["atp_at_id"];
$atp_ref = $myrow["atp_ref"];
$atp_start = $myrow["atp_start"];
$atp_end = $myrow["atp_end"];
$atp_quoted = $myrow["atp_quoted"];
$atp_awarded = $myrow["atp_awarded"];
$atp_rogress = $myrow["atp_rogress"];
$atp_cpl_inv = $myrow["atp_cpl_inv"];
$atp_invoice = $myrow["atp_invoice"];
$atp_paym_pb = $myrow["atp_paym_pb"];
$atp_completed = $myrow["atp_completed"];
$atp_modified = $myrow["atp_modified"];
?>
<input type=hidden name="atp_id" value="<?php echo $atp_id ?>">
<table border=0>
<tr><td><font face=Arial size=2>Address</font></td><td>
<SELECT name = "atp_at_id">
<?php
$resultoptiontadr = mysql_query ("SELECT * FROM ataddress ORDER BY at_name1");
while($opt_lineadr=mysql_fetch_array ($resultoptiontadr))
if ($opt_lineadr[0]== $codetargetadr) {
echo "<option SELECTED value=$opt_lineadr[0]>$opt_lineadr[1] > $opt_lineadr[2]</option>\n";
} else {
echo "<option value=$opt_lineadr[0]>$opt_lineadr[1] > $opt_lineadr[2]</option>\n";
}
?>
</SELECT></td></tr>
<tr><td>Project Nr</td><td><input type="Text" name="atp_ref" size="10" value="<?php echo $atp_ref ?>">
<tr><td>Starting Date</td><td><input type="Date" name="atp_start" size="10" value="<?php echo $atp_start ?>">
<tr><td>Closing Date</td><td><input type="Date" name="atp_end" size="10" value="<?php echo $atp_end ?>">
<tr><td>Quoted</td><td><input type="Text" name="atp_quoted" size="10" value="<?php echo $atp_quoted ?>"> Quote Nr
<tr><td>Awarded</td><td><input type="Text" name="atp_awarded" size="1" value="<?php echo $atp_awarded ?>"> Y or empty
<tr><td>In Progress</td><td><input type="Text" name="atp_rogress" size="1" value="<?php echo $atp_rogress ?>"> Y or empty
<tr><td>Completed before Invoicing</td><td><input type="Text" name="atp_cpl_inv" size="1" value="<?php echo $atp_cpl_inv ?>"> Y or empty
<tr><td>Invoiced</td><td><input type="Text" name="atp_invoice" size="10" value="<?php echo $atp_invoice ?>"> Invoice Number
<tr><td>Payment Delinquent</td><td><input type="Text" name="atp_paym_pb" size="1" value="<?php echo $atp_paym_pb ?>"> Y or empty
<tr><td>Project completed</td><td><input type="Text" name="atp_completed" size="1" value="<?php echo $atp_completed ?>"> Y or empty
</table>
<input type="Submit" name="submit" value="Enter information">
<a href="javascript:history.go(-1)">BACK</a>
</form>
now I want to replace, or to use additionnally to this portion of script
<tr><td>Starting Date</td><td><input type="Date" name="atp_start" size="10" value="<?php echo $atp_start ?>">
<tr><td>Closing Date</td><td><input type="Date" name="atp_end" size="10" value="<?php echo $atp_end ?>">
an icon to link to a calendar, where from I will get the date back and load it back into the form
to do that I developped a calendar script:
<?php
session_start();
echo "$v_display<br>";
include "include/get_root_da_erp.inc";
//parameters
$border_color = green;
$border_thickness = 3;
$title_background = "#FFD700"; // #FFD700 = gold
$font = arial;
$title_font_size = 2;
$title_font_color = green;
$day_name_font_size = 2; // Mon, Tue, Wed, ...
$day_name_font_color = brown;
$day_name_background = "#FFCCFF";
$day_background_color = "CCCCCC"; //#CCCCCC light grey 1,2,3,4,5,6,7,....
$day_font_color = blue;
$day_font_size = 3;
$language = e;
if ( $month_chosen == '') { $base = date ("D M d m Y"); } else {
if ( $month_chosen == 'plus') { $base = date ("D M d m Y", mktime (0,0,0,$mth+1,$dy,$yr)); }
if ( $month_chosen == 'minus') { $base = date ("D M d m Y", mktime (0,0,0,$mth-1,$dy,$yr)); }
}
$new_day = substr($base,8,2);
$new_month = substr($base,11,2);
// getting the full name of the month like: 'September'
$resultmn = mysql_query ("SELECT * FROM calgal WHERE cag_typ = 'MONTH' && cag_lg ='$language' && cag_abr3 = '$new_month'",$db);
while ($myrowmn = mysql_fetch_array($resultmn)) {
$new_month_name = $myrowmn["cag_descr"];
}
$new_year = substr($base,14,4);
$new_day_name_short = substr($base,0,3);
//getting the weekday nr like: 1,2,3,...
$resultdnr = mysql_query ("SELECT * FROM calgal WHERE cag_typ = 'DAY' && cag_lg ='$language' && cag_abr5 = '$new_day_name_short'",$db);
while ($myrowdnr = mysql_fetch_array($resultdnr)) {
$v_day_nr = $myrowdnr["cag_abr3"];
}
// getting the last day of the month
$last_day = cal_days_in_month(CAL_GREGORIAN, $new_month, $new_year);
echo "<br><table border=$border_thickness bordercolor=$border_color><tr><td colspan=7 bgcolor=$title_background>";
echo "<table border=0 width=100%><tr><td align=left width=30><a href=\"calendar.php?month_chosen=minus&&dy=$new_day&&mth=$new_month&&yr=$new_year\"><img src=\"images_ATFS/b_minus.gif\" width=30 height=20 alt=\"previous month\" border=0></a><td align=center><b><font face=$font size=$title_font_size color=$title_font_color>$new_month_name $new_year</font></b><td align=right width=30><a href=\"calendar.php?month_chosen=plus&&dy=$new_day&&mth=$new_month&&yr=$new_year\"><img src=\"images_ATFS/b_plus.gif\" width=30 height=20 alt=\"next month\" border=0></a></table>";
echo "<tr>";
// here are the name of the days 'Monday to Sunday'
$resultdyname = mysql_query ("SELECT * FROM calgal WHERE cag_typ = 'DAY' && cag_lg ='$language'",$db);
while ($myrowdyname = mysql_fetch_array($resultdyname)) {
$v_dayname_short = substr($myrowdyname["cag_descr"],0,3);
echo "<td bgcolor=$day_name_background><font face=$font size=$day_name_font_size color=$day_name_font_color>$v_dayname_short</font>";
}
echo "<tr>";
//listing the days, positionning the 1st day on the correct weekday
for($i = 1; $i <= $last_day; $i++){
$v_date_calcul_date = date ("D d-m-Y", mktime (0,0,0,$new_month,$i,$new_year));
$v_day_name_short = date ("D", mktime (0,0,0,$new_month,$i,$new_year));
$resultdyname2 = mysql_query ("SELECT * FROM calgal WHERE cag_typ = 'DAY' && cag_lg ='$language' && cag_abr5='$v_day_name_short'",$db);
while ($myrowdyname2 = mysql_fetch_array($resultdyname2)) {
$v_weekday = 100+$myrowdyname2["cag_abr3"]-100;
if ( $v_weekday == 1 ) { echo "<tr>"; }
if ( $i == 1 && $v_weekday > 1) {
for ($j = 1; $j< ($v_weekday); $j++ )
{ echo "<td> "; }
}
echo "<td align=right bgcolor=$day_background_color><a href=\"cal_date.php?dy=$i&&mth=$new_month&&yr=$new_year&prog=$prog\" style=\"text-decoration:none\"><font face=$font size=$day_font_size color=$day_font_color>$i</font></a>";
}
if ( $v_weekday < 7 && $i == $last_day) { for ($k = $v_weekday; $k < 7; $k++ ) { echo "<td> "; } }
}
echo "</table>";
?>
How does it work? I tried with an image linked to the calendar.php script, but it was not working
Any idea ? By the way, Happy New Year to all of you