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
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
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 4 times)
Viewed : 33364
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
PHP4 session helper HTML file.
Categories : PHP, Java Script, HTML and PHP, Sessions
phpCards - PHP/mySQL postcard script with web based admin to add, edit, and delete cards and categories. Very easy to install.
Categories : PHP, Complete Programs, HTML and PHP, MySQL
Storing / Retrieving pictures from database This can be used for banner / ads exchange. very useful for people developing big portal with ads in the site........
Categories : PHP, MySQL, Databases, HTML and PHP
Local-to-user date and time display regardless of time zone or where the website's server is located
Categories : PHP, Date Time, HTML and PHP, Java Script
PHP3 generated gif / javascript mouseover.
Categories : PHP, Java Script, MySQL
html split bar used to split in multiple pages a database result
Categories : HTML and PHP, Databases, MySQL, PHP
Database resultset navigation
Categories : PHP, HTML and PHP, Databases, MySQL, Navigation
A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL
Remote Scripting: send form POST data to a script and insert the results into a page without refreshing the page.
Categories : PHP, AJAX, HTML and PHP, Java Script
Linked comboboxes with php-mysql & javascript
Categories : PHP, Java Script, Databases, MySQL
Validator 98 - a PHP-script to generate form-validation-code in JavaScript.
Categories : Complete Programs, Java Script, PHP, HTML and PHP
Record Set Paging with PHP (RSP)
Categories : PHP, MySQL, Navigation, Databases, HTML and PHP
DDN FFA Network Script
Categories : PHP, MySQL, Complete Programs, HTML and PHP, Databases