Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CheckBox Value

Status
Not open for further replies.

Oasmat1983

Technical User
Jul 2, 2008
1
US
I have a question would there be Php script I can use that can change a Value of a checkbox automatically every 7 Days so I won't have to do it manually?

If someone can help me with it I really do appreciate it.

Thank you,
 
such a thing would be very easy to do, yes. i doubt whether there are any pre-written scripts though.

something like this might work if all you want is an incrementing value.

Code:
<?php
/**
 * function to return and update dynamic checkBoxValue
 * @return html checkbox string
 */
function getCheckBox(){
	$file = 'checkboxValue.txt';
	if (file_exists($file)){
		$contents = file($file);
		//we're only interested in the first line
		list($date, $value) = explode ('~~', $contents[0]);
		if ( strtotime('-1 week') > $date){	//check if value more than a week old
			 $value++; 	//increment value
			 file_put_contents($file, time() . '~~' . $value);
		}
	} else {
		$value = 0;	//start the ball rolling
		file_put_contents($file, time() . '~~' . $value);
	}
	
	return <<<HTML
<input type="checkbox" name="checkbBoxName" value="$value" /> $value
HTML;
}
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top