Page 1 of 1

Insert Multiple Value

Posted: Wed May 05, 2010 8:42 am
by nitediver
How to submit time and date for these code, since the field is separated how to insert the value into one field in table?

Code: Select all

<?

function fdate(){
//Date
echo "<select name=\"fdate\">";
for($d=1; $d<32; $d++){
echo ("<option>$d</option>");
}
echo "</select>";

//Month
echo "<select>";
for($m=1; $m<13; $m++){
echo ("<option>$m</option>");
}
echo "</select>";

//Year
$d = date(Y);
$b = date(Y)-2;
echo "<select>";
for($d; $d>$b; $d--){
echo ("<option>$d</option>");
}
echo "</select>";
}
?>

<table id="conf">
<form action="confirm.php" method="post" name="confirm">
<tr>
	<td>Name</td>
	<td><input type="text" name="conf_name"></td>
</tr>
<tr>
	<td>Number</td>
	<td><input type="text" name="conf_number"></td>
</tr>
<tr>
	<td>Time</td>
	<td>
	<input type="text" name="hr" size="2">
	<input type="text" name="min" size="2">
	<input type="text" name="sec" size="2">
	</td>
</tr>
<tr>
	<td>Date</td>
	<td><? fdate(); ?></td>
</tr>
<tr>
	<td>
	<input type="submit" name="post" value="Submit">
	<input type="reset" name="clear" value="Reset">
	</td>
</tr>
</form>
</table>

Re: Insert Multiple Value

Posted: Wed May 05, 2010 10:40 am
by AbraCadaver
First, you need to name all three selects, maybe: name="day", name="month", name="year"? Then just put them together:

Code: Select all

$date = $_POST['year'] . '-' . $_POST['month'] . '-' .  $_POST['day'];

Re: Insert Multiple Value

Posted: Wed May 05, 2010 11:18 am
by nitediver
Thanks, I really need that.