Insert Multiple Value

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nitediver
Forum Contributor
Posts: 109
Joined: Tue Feb 24, 2009 9:05 am

Insert Multiple Value

Post 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>
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Insert Multiple Value

Post 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'];
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
nitediver
Forum Contributor
Posts: 109
Joined: Tue Feb 24, 2009 9:05 am

Re: Insert Multiple Value

Post by nitediver »

Thanks, I really need that.
Post Reply