PCHomepage
Programmer
I am creating a class of private functions to use for generating date/time selectors on a form but I am having difficulty making it select nothing at all! That is, it is set up to pre-populate the selectors from the Unix timestamp field of the database and there is no problem there but if the database cell is empty, it is still populating it with January 01, 1970. I understand why it is doing it but am not sure how to make it NOT do it! I need it to either submit zeros or, better yet, submit nothing at all.
Here is one of the private classes but the rest are similar:
with an empty database date field, it is showing:
Here is one of the private classes but the rest are similar:
Code:
public function createDaySelect() {
//create the day select
$html = "<select name=\"day".$this->selectorid."\" id=\"day".$this->selectorid."\">\n";
$html .= "<option value=\"00\">Select Day</option>\n";
for ($i = 1; $i <= $this->numDays; $i++) {
$html .= "<option value=\"".sprintf("%02d", $i)."\"";
$html .= ($this->day == $i) ? " SELECTED>" : ">";
$html .= sprintf("%02d", $i)."</option>\n";
}
$html .= "</select>\n";
return $html;
}
with an empty database date field, it is showing:
Code:
<select name="day1" id="day1">
<option value="00">Select Day</option>
<option value="01" SELECTED>01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option> . . .