WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search


Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - השוואת מחירים בסופר
ZeroLag.com
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : This PHP function creates dropdown select lists for time and date that you can change, outputs a 14 char MySQL timestamp in a text field
Categories : PHP, MySQL, Java Script, HTML and PHP Update Picture
Les Keniston
Date : Aug 13th 2000
Grade : 3 of 5 (graded 5 times)
Viewed : 34817
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Les Keniston
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

Enjoy this - I'm sure it could be more elegant, but I couldn't find something like this anywhere
else. Pull your hair out on more important programming problems! If you like it, or improve
upon it, drop me a line.

p.s. I really love Weberdev -- it rules PHP like Odin rules Valhalla!

call the function like this:
<?PHP
stamper($previous_value);
?>

__________________________________

<?PHP
function stamper($previous_value) {

// your constants
$form_name = "form1";
$store_stamp_field = "datestamp";

// looks for previous 14 char stamp or defaults to now
if (!$previous_value) {
$my_stamp = date("YmdHis");
} else {
$my_stamp = $previous_value;
}

// parses the timestamp & digests it into useful variables
$year=substr($my_stamp,0,4);
$month=substr($my_stamp,4,2);
$day=substr($my_stamp,6,2);
$hour=substr($my_stamp,8,2);
$minute=substr($my_stamp,10,2);
$second=substr($my_stamp,12,2);

// here you can set your ("starting value", "range") for each
$year_range = array("2000","11");
$month_range = array("01","12");
$day_range = array("01","31");
$hour_range = array("00","24");
$minute_range = array("00","60");
$second_range = array("00","60");
$names = array("month","day","year","hour","minute","second");
$names_for_stamp = array("year","month","day","hour","minute","second");


// this drops in some javascript to do the onChange event handler for each select list
echo "<script language=\"JavaScript\">\n";
echo "function adj_timestamp () {\n";
echo "var each_field = new Array(" . count($names) . ");\n";
for ($i=0;$i<count($names);$i++) {
echo "each_field[" . $i . "] = document." . $form_name . "." . $names_for_stamp[$i] . ".options
[document." . $form_name . "." . $names_for_stamp[$i] . ".selectedIndex].value;";
}
echo "var timestamp = ";
for ($i=0;$i<count($names);$i++) {
if ($i!=(count($names)-1)) {
echo "each_field[" . $i . "] + ";
} else {
echo "each_field[" . $i . "];\n";
}
}
echo "document." . $form_name . "." . $store_stamp_field . ".value = timestamp;\n";
echo "}\n";
echo "</script>\n";

// this creates the selects and add the JS event handler
for ($i=0;$i<count($names);$i++) {
echo "<select name=\"$names[$i]\" onChange=\"adj_timestamp();\">\n";
$this_one = ${"$names[$i]" . "_range"};
for ($k=0;$k<$this_one[1];$k++) {
$each_val = $this_one[0]+$k;
if (strlen($each_val)<2) {
$each_val = sprintf("%02d", $each_val);
}
if (${"$names[$i]"}==$each_val) {
$selected=" selected";
} else {
$selected="";
}
echo "<option value=\"$each_val\"$selected>$each_val</option>\n";
}
echo "</select>\n";
}

//this creates the initial timestamp
$the_stamp = $year . $month . $day . $hour . $minute . $second;

//this holds the dynamic timestamp value, make it hidden once you get the hang of how it all
works
echo "<input type=\"text\" name=\"$store_stamp_field\" value=\"$the_stamp\">\n";
}
?>



Pull Down Surfing - Surf on Change
Categories : Java Script, MySQL, HTML and PHP, PHP, Databases
OverEasy - PHP generated JavaScript to do mouseovers on your pages. Modify one file and one function does it all for you!
Categories : PHP, Java Script, HTML and PHP, MySQL
DDN FFA Network Script
Categories : PHP, MySQL, Complete Programs, HTML and PHP, Databases
dynamic table columns
Categories : PHP, HTML and PHP, Arrays, Databases, MySQL
Complete, simple working example of login screen and check on a unique page using php functions, cookies and mysql database.
Categories : PHP, Cookies, MySQL, HTML and PHP, Authentication
Convert date's in YYYY-MM-DD (i.e. mysql format) into PHP3 timestamps. Also Find the difference in days between two PHP3 timestamps.
Categories : HTML and PHP, PHP, MySQL, Date Time
Complex paging with no resultset limit
Categories : PHP, MySQL, Databases, Output Control, HTML and PHP
phpFormGenerator for Dynamic Form Generation from MySQL
Categories : PHP, PHP Classes, MySQL, Databases, HTML and PHP
This is a redirection program which is as good as the come.to v3 url redirection, complete with admin interface all clients stored in mysql
Categories : PHP, MySQL, Ecommerce, HTML and PHP, Complete Programs
A Complete table(ADD,EDIT,VIEW,DELETE) management System PHP,MYSQL, JAVASCRIPT
Categories : PHP, MySQL, Java Script, Databases
A PHP useradmin for MySQL. Uploading is easy. The only thing you need is PHP and MySQL installed!
Categories : MySQL, Databases, PHP, HTML and PHP
A Simple sign up script with PHP and JavaScript validations.
Categories : PHP, Java Script, MySQL, Databases
PHP mySQL learning example This is a complete program to modify tables in a mySQL database on a nice and neat way.
Categories : PHP, MySQL, Complete Programs, HTML and PHP
Function that allows a Javascript cookie to be set after HTML has been outputted to the page.
Categories : PHP, Java Script, Cookies, HTML and PHP
Validator 98 - a PHP-script to generate form-validation-code in JavaScript.
Categories : Complete Programs, Java Script, PHP, HTML and PHP