473,473 Members | 1,837 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Dealing with Dates

(This has been posted on the PHP.general group also.)

I'm writing an app where I want the user to be able to change a date on
a record. Date field is 'TngDate'. I can pull the record from the
mySql database, split it into day/month/year, put each in a drop down
box. What I can't seem to do is collect the modified entries,
reassemble them into a single variable and pass it on to the update
script. I admit to being a newbie at this and most of my scripts
(including this one) come from examples that I have found either on the
'Net or in books. The script below is the script I have so far.
It's in an include file. I would appreciate any help.

<?php
$monthName = array(1=> "January", "February", "March", "April", "May",
"June", "July", "August", "September", "October", "November",
"December"); $f_today = $formValues["TngDate"]; echo $f_today;

/* create form containing date selection list */
echo "<form method='post'>\n";

/* build selection list for the month */
$todayMO = substr($f_today,5,2);
echo "<select name='dateMO'>\n";
for ($n=1;$n<=12;$n++)
{
echo "<option value=$n\n";
if ($todayMO == $n)
{
echo " selected";
}
echo "> $monthName[$n]\n";
}
echo "</select>";

/* build selection list for the day */
$todayDay = substr($f_today, 8,2);
echo "<select name='dateDay'>\n";
for ($n=1;$n<=31;$n++)
{
echo "<option value=$n\n";
if ($todayDay == $n)
{
echo " selected";
}
echo "> $n\n";
}
echo "</select>\n";

/* build selection list for the year */
$startYr = substr($f_today, 0,4);
echo "<select name='dateYr'>\n";
for ($n=$startYr;$n<=$startYr+3;$n++)
{
echo "<option value=$n\n";
if ($startYr == $n)
{
echo " selected";
}
echo "> $n\n";
}
$newDate=date("Y-m-d", mktime(0,0,0, $todayMO, $todayDay, $startYr));
echo "</select>"; $newTngDate = strtotime("$newDate"); echo
"</form>\n"; ?>

Jul 17 '05 #1
1 1606
cc********@hillcountry.org wrote:
(This has been posted on the PHP.general group also.)

I'm writing an app where I want the user to be able to change a date on
a record. Date field is 'TngDate'. I can pull the record from the
mySql database, split it into day/month/year, put each in a drop down
box. What I can't seem to do is collect the modified entries,
reassemble them into a single variable and pass it on to the update
script. I admit to being a newbie at this and most of my scripts
(including this one) come from examples that I have found either on the
'Net or in books. The script below is the script I have so far.
It's in an include file. I would appreciate any help.
You need a form action, otherwise the form is posted nowhere:
<form method='post' action='somescript.php' name='something'>
If the form is supposed to process it's own data, use
$_SERVER['PHP_SELF'] to make the script action itself.

Before you close the form, you need a submit button like
<input type='submit' value='Submit' name='submit'>

Your receiving script should look for the values in the predefined
variable array $_POST - check the manual at www.php.net for more
information.

/* create form containing date selection list */
echo "<form method='post'>\n"; This has no action

/* build selection list for the month */
$todayMO = substr($f_today,5,2);
echo "<select name='dateMO'>\n";
for ($n=1;$n<=12;$n++)
{
echo "<option value=$n\n";
if ($todayMO == $n)
{
echo " selected";
}
echo "> $monthName[$n]\n";
}
echo "</select>"; This simply gives a drop down list of months..... it will allow the use
to select from that list. The other option lists have been removed for
clarity.

$newDate=date("Y-m-d", mktime(0,0,0, $todayMO, $todayDay, $startYr));
echo "</select>"; $newTngDate = strtotime("$newDate"); echo
"</form>\n"; ?>

You are doing nothing with this at all, except echo-ing the closing form
tag - you need to be able to submit the data that your user has changed.

when you have posted the data, your receiving script will be able to
find them. The server (where PHP works) is not aware of any changes
until they have been submitted.

HTH, regards,

Andy
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: PW | last post by:
<rant> Sorry guys, but I just have to whinge. Dates in ASP are a total pain in the butt! I seem to get caught out so many times. I realise its my own fault, but going from the posts in this...
10
by: Colin Steadman | last post by:
I'm a stupid ASP programmer and I dont do Javascript (except for very simple tasks anyway), and I'm in a bit of a predicament. I've used a javascript table sorting script from here: ...
1
by: Igor Kramarsich - EDIT | last post by:
I'm having problems dealing with dates in my queries/SQL code. I need a search digit date. In form define date field without format I receive results. But I go to define date filed with short date...
1
by: Angela | last post by:
Hi I am building a very simple data entry system with many forms and input textboxes. When I leave any part of the form empty (it allows nulls) it seems to touch the field in the DB and the...
3
by: Mage | last post by:
Hi, can pgsql acceppt invalid date values? Sometimes it would be nice to convert 2003-02-29 to 2003-03-01 or to 2003-02-28 automatically instead of throwing back an error message. Mage ...
12
by: Dixie | last post by:
I am trying to calculate the number of workdays between two dates with regards to holidays as well. I have used Arvin Meyer's code on the Access Web, but as I am in Australia and my date format is...
1
by: pitfour.ferguson | last post by:
My dbase has the start date and end date of each visit. How can I ask Access to list the day of the week of the start (easy), end (easy) and, more importantly, the dates of the visit itself - ie...
0
by: BillE | last post by:
PROBLEM SUMMARY -- I use "Response.Cache.SetCacheability(HTTPCacheability.NoCache)" to force a page to reload instead of displaying cached content. However, I don't really want to reload the...
12
by: GaryDean | last post by:
Is there any good way in which to deal with null datetimes. For instance, I can't seem to find anything that will pass a null value in a datetime parameter to another method. Convert.dbnull will...
2
by: Jim Carlock | last post by:
(1) Does PHP provide any way to handle dates prior to 1980? I know there's problems with Microsoft Windows NT and all Windows NT operating systems will allow a date prior to 1980 to be placed...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.