i've searched and searched and maybe i found actually the right post but nothing worked for me so sorry for any duplication but maybe someone can help me out.
I have a php that gets me a form with multiple rows (based on an form input before).
Here's the php that creates the input table:
<html>
<head></head>
<body>
New report with EEM Number:<input type="text" name="eemnumber" />
<tr>
<td>Expense Date</td>
<td>Category</td>
<td>Vendor</td>
<td>Receipt Amount</td>
<td>Currency</td>
<td>Payment Amount</td>
<td>Currency</td>
<td>Payment Type</td>
<td>Country</td>
</tr>
<?php
$rows = $_POST['rows'];
$n = 0;
while($n < $rows)
{
$n++;
?>
<tr>
<td><input type="date" name="expensedate"/><br /></td>
<td><select name="category">
<option value="AirFare">AirFare</option> />
<option value="AutoRental">Auto Rental - Employee</option> />
<option value="DailyAllowance">Daily Allowance Standard</option> />
<option value="Gasoline">Gasoline - Auto Rental</option> />
<option value="Lodging">Lodging (Hotel) - Room / Tax</option> />
<option value="Meals">Meals / Entertain - HP only, Travel</option> />
<option value="Misc">Miscellaneous</option> />
<option value="Taxi">Taxi / Subway / Bus / Train</option> />
<br/>
</td>
<td><input type="text" name="vendor"/><br /></td>
<td><input type="text" name="receiptamount"/>
</td>
<td><select name="currrec">
<option value="EUR">EUR</option> />
<option value="SEK">SEK</option> />
<option value="USD">USD</option> />
</td>
<td><input type="text" name="paymentamount"/>
</td>
<td><select name="currpay">
<option value="EUR">EUR</option> />
<option value="SEK">SEK</option> />
<option value="USD">USD</option> />
</td>
<td><select name="paytype">
<option value="cash">Cash</option> />
<option value="cc">Credit Card</option> />
<br/>
</td>
<td><select name="country">
<option value="DE">Germany</option> />
<option value="SE">Sweden</option> />
<option value="US">USA</option> />
<br/>
</td>
</tr>
<?PHP
}
?>
</table>
</div>
<p>
<input type="submit"/>
</form>
<!-- End of FORM -->
Back
</body>
</html>
So once all data was entered I click on Submit and would of course like to get every line into my DB. Here's the script i tried do use but only gets me the last...
<?php
$con=mysqli_connect("localhost","user","pass","db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$eemnumber=$_POST['expensedate'];
$expensedate=$_POST['expensedate'];
$category=$_POST['category'];
$vendor=$_POST['vendor'];
$receiptamount=$_POST['receiptamount'];
$currrec=$_POST['currrec'];
$paymentamount=$_POST['paymentamount'];
$currpay=$_POST['currpay'];
$paytype=$_POST['paytype'];
$eemnumber=$_POST['eemnumber'];
$country=$_POST['country'];
$sql="INSERT INTO tbl_eem_data
(ExpenseDate, Category, Vendor, ReceiptAmount, CurrRec, PaymentAmount, CurrPay, PayType, EEMNumber, Country)
VALUES
$expensedate,
$category,
$vendor,
$receiptamount,
$currrec,
$paymentamount,
$currpay,
$paytype,
$eemnumber,
$country)";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
mysqli_close($con);
header("location:index.php");
?>
Anyone any clue?
Thanks!!!
You need to change form Structure and form Fields
<?php
$rows = $_POST['rows'];
$n = 0;
while($n < $rows)
{
$n++;
?>
<tr>
<td><input type="date" name="expensedate[<?echo $n?>]"/><br /></td>
<td><select name="category">
<option value="AirFare">AirFare</option> />
<option value="AutoRental">Auto Rental - Employee</option> />
<option value="DailyAllowance">Daily Allowance Standard</option> />
<option value="Gasoline">Gasoline - Auto Rental</option> />
<option value="Lodging">Lodging (Hotel) - Room / Tax</option> />
<option value="Meals">Meals / Entertain - HP only, Travel</option> />
<option value="Misc">Miscellaneous</option> />
<option value="Taxi">Taxi / Subway / Bus / Train</option> />
<br/>
</td>
<td><input type="text" name="vendor[<?echo $n?>]"/><br /></td>
<td><input type="text" name="receiptamount[<?echo $n?>]"/>
</td>
<td><select name="currrec">
<option value="EUR">EUR</option> />
<option value="SEK">SEK</option> />
<option value="USD">USD</option> />
</td>
<td><input type="text" name="paymentamount[<?echo $n?>]"/>
</td>
<td><select name="currpay[<?echo $n?>]">
<option value="EUR">EUR</option> />
<option value="SEK">SEK</option> />
<option value="USD">USD</option> />
</td>
<td><select name="paytype[<?echo $n?>]">
<option value="cash">Cash</option> />
<option value="cc">Credit Card</option> />
<br/>
</td>
<td><select name="country[<?echo $n?>]">
<option value="DE">Germany</option> />
<option value="SE">Sweden</option> />
<option value="US">USA</option> />
<br/>
</td>
</tr>
<?PHP
}
?>
<input type="hidden" name="rows" value="<?echo $n?>" />
Then apply similar loop to fetch those values.
You also need to have hidden variable which stores total number of rows you have.
Thanks
You seem to be missing an open parenthesis ( in your SQL right after VALUES.
Fix it and hopefully it will work: VALUES ( . . . )
Basically, run this test:
HTML:
<input type="text" name="key" value="1" />
<input type="text" name="key" value="2" />
PHP:
<?
print_r($_POST);
?>
And then run this:
HTML:
<input type="text" name="key[]" value="1" />
<input type="text" name="key[]" value="2" />
PHP:
<?
print_r($_POST);
?>
See if you can make any conclusions with this, and let me know what you think.
You are generating form fields based on the number of $rows received from the Request.
<form ... <!- this line was missing in your code -->
$rows = $_POST['rows'];
while($n < $rows)
...
</form>
And after submit, you are not reading parameters into arrays.
$eemnumber=$_POST['expensedate']; /* this is wrong again */
$expensedate=$_POST['expensedate'];
$category=$_POST['category'];
$vendor=$_POST['vendor'];
Which lead the last value from the submitted array values assigned to the variable in concern.
And hence you see that only last row read and pushed into DB.
Change your code accordingly and it should be working.
Refer to:
PHP: Reading POST data with arrays
Related
Here is a small section of my form. It is set up that a user can add information about one munro, or multiple. Hence the use of arrays for input boxes, check boxes and select option boxes.
<fieldset class="row1">
<H2>Munro Details</H2>
<table id="munroTable" class="form" border="0">
<tbody>
<tr>
<td><input type="checkbox" required="required" name="chk[]" checked="checked" /></td>
<td>
<label>Name</label>
<input class = "textbox" type="text" maxlength = "30" required="required" name="name[]">
</td>
<td>
<label>Height (metres)</label>
<input class = "textbox" type="number" maxlength = "5" required="required" name="height[]">
</td>
<td>
<label>Classification</label>
<select name = "classification[]">
<optgroup label="Scottish Hills">
<option value="Munro">Munro</option>
<option value="Corbett">Corbett</option>
<option value="Graham">Graham</option>
<option value="Donald">Donald</option>
</optgroup>
<optgroup label="Non Scottish Hills">
<option value="Furth">Furth</option>
<option value="Hewitt">Hewitt</option>
<option value="Wainwright">Wainwright</option>
<option value="Brikett">Brikett</option>
</optgroup>
<optgroup label="UK wide">
<option value="Marilyn">Marilyn</option>
</optgroup>
</select>
</td>
<td>
<label>Topped?</label>
<input type="checkbox" value = "Yes" name="topped[]" checked="checked">
</td>
</tr>
</tbody>
</table>
<p>
<input class = "myButton" type="button" value="Add Munro" onClick="addRow('munroTable')" />
<input class = "myButton" type="button" value="Remove Munro" onClick="deleteRow('munroTable')" />
</p>
</fieldset>
The issue I'm having is with the select option for "classification".
When I use echo "<br>All data".print_r($_POST); so see what data is being sent sucessfully, the classification doesn't show up.
I'm assuming it is something very simple, but I just can't find it.
Thanks for taking the time to look.
I have a form in php to select 3 choices , when i select all three no error is shown, but when i select two choices it shows error but choice is saved in data base, and shows record saved, but also show Notice: Undefined index: hb3 in C:\wamp\www\uni1\admin\courses.php on line 14
07/25/2014
<?php
include('auth.php');
include('conect.php'); $msg='';
if(isset($_POST['save']))
{
$category = $_POST['category'];
$cname = $_POST['cname'];
$code = $_POST['code'];
$type = $_POST['type'];
$dur = $_POST['dur'];
$fee = $_POST['fee'];
$hb1 = $_POST['hb1'];
$hb2 = $_POST['hb2'];
$hb3 = $_POST['hb3'];
$catid =mysql_insert_id();
$sql = mysql_query("select * from category where catid='$category'");// to get category code from category table
$rs = mysql_fetch_array($sql);
mysql_query("INSERT INTO courses1 (catid,cname, code, type, dur, fee, hb1, hb2, hb3)
VALUES ('$category','$cname','$code','$type','$dur','$fee','$hb1','$hb2','$hb3')");
$msg = '<h3>Record Saved</h3>';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>courses</title>
<link rel="stylesheet" type="text/css" href="headerstyle.css" />
</head>
<body>
07/25/2014
<div class="fixx"><?php include('header.php');?></div>
<div class="tabl">
<table width="700" border="0">
<tr>
<td>
<form method="post" action="courses.php">
<table width="700" border="1" cellpadding="10">
<tr>
<td colspan="2"><h3> ADD COURSES | EDIT </h3></td>
</tr>
<tr>
<td colspan="2"><?php echo $msg;?></td>
</tr>
<tr>
<td width="174"><h4>Select Category </h4></td>
<td width="674"><label for="category"></label>
<select name="category" id="category">
<?php $qre = mysql_query("select * from category ORDER BY name");
while($res = mysql_fetch_array($qre))
{
echo '<option value="'.$res['catid'].'">'.$res['name'].'</option>';
}
?>
</select> </td>
</tr>
<tr>
<td width="174"><h4>Enter Course Name</h4></td>
<td width="674"><label for="cname"></label>
<input name="cname" type="text" id="cname" size="70" /></td>
</tr>
<tr>
<td><h4>Course Code</h4></td>
<td><input type="text" name="code" id="code" /></td>
</tr>
<tr>
<td><h4>Type</h4></td>
<td><label for="type"></label>
<select name="type" id="type">
<option value="Month"><h4>Month</h4></option>
<option value="Semester"><h4>Semester</h4></option>
<option value="Year"><h4>Year</h4></option>
</select></td>
</tr>
<tr>
<td><h4>Duration</h4></td>
<td><p>
<select name="dur" id="dur">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>
</p></td>
</tr>
<tr>
<td><h4>Fee</h4></td>
<td><input type="text" name="fee" id="fee" /></td>
</tr>
<tr>
<td><h4>Mode</h4></td>
<td><h4>Online
<input type="checkbox" name="hb1" id="hb1" value="online" /></h4><br />
<h4>Private
<input type="checkbox" name="hb2" id="hb2" value="private" /></h4>
<br />
<h4>Regular
<input type="checkbox" name="hb3" id="hb3" value="regular" />
</h4> <br />
</label></td>
</tr>
<tr>
<td><input type="submit" name="save" id="save" value="Submit" /></td>
</tr></h2>
</table>
</form>
</td>
</tr>
</table>
</div>
</body>
</html>
Please solve my problem
There is error because when you are selecting only two choices then third choice has null means no value
$hb3 has no value for choice
you should check is value set or not if not then assign some default values
$hb1 = isset($_POST['hb1'])?$_POST['hb1']:'';
$hb2 = isset($_POST['hb2'])?$_POST['hb2']:'';
$hb3 = isset($_POST['hb3'])?$_POST['hb3']:'';
You should do like that if don't want notice "Undefined index"
$hb1 = isset($_POST['hb1'])?$_POST['hb1']:'';
$hb2 = isset($_POST['hb2'])?$_POST['hb2']:'';
$hb3 = isset($_POST['hb3'])?$_POST['hb3']:'';
use hidden filed
<input type="hidden" id="hb1_" name="hb1" value="-1">
<input type="checkbox" id="hb1" name="hb1" value="online" />
<input type="hidden" id="hb2_" name="hb2" value="-1">
<input type="checkbox" id="hb2" name="hb2" value="private" />
<input type="hidden" id="hb3_" name="hb3" value="-1">
<input type="checkbox" id="hb3" name="hb3" value="regular" />
When checkox in not checked, then $_POST doesn't contain given key, so you cannot assign its value. Whenever you use checkbox, assign given post value like this:
$hb3 = isset($_POST['hb3'])?$_POST['hb3']:'';
then in case of undefined value you will assign an empty string and you will not see those notices.
I have this script. When I select the date then I get the data by selecting date, but I want to set this with timestamp
<link rel="stylesheet" type="text/css" href="tcal.css" />
<script type="text/javascript" src="tcal.js"></script>
<form action="index.php" method="get">
From : <input type="text" name="d1" class="tcal" value="" />
<input type="submit" value="Search">
</form>
<table id="resultTable" data-responsive="table" style="text-align: left; width: 400px;" border="1" cellspacing="0" cellpadding="4">
<thead>
<tr>
<th> Birtday </th>
<th> Name </th>
<th> Gender </th>
</tr>
</thead>
<tbody>
<?php
include('connect.php');
if (isset($_GET["d1"])) { $d1 = $_GET["d1"]; } else { $d1="0000-00-00"; };
$result = $db->prepare("SELECT * FROM birthday WHERE date = :a");
$result->bindParam(':a', $d1);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<tr class="record">
<td><?php echo $row['date']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['gender']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
How I set timestamp with this script
Just use date() to echo out today's date as the value of your d1 input field:
<link rel="stylesheet" type="text/css" href="tcal.css" />
<script type="text/javascript" src="tcal.js"></script>
<form action="index.php" method="get">
From : <input type="text" name="d1" class="tcal" value="<?php echo date("m/d/Y"); ?>" />
<input type="submit" value="Search">
</form>
Ya the date - function will give all the information you need. If you havn't worked with it or just in case you are new to PHP, have a look at the documentation for finding the right date parameters.
For example:
date("d.m.Y") //outputs: 13.03.2014
date("n.d.Y") //outputs: 3.13.2014
date("m.d.y") //outputs: 03.13.14
The whole documentation can be found here: http://php.net/manual/en/function.date.php
EDIT::
So if I got you right you are looking for something simular like this:
<select class="Calendar" id="cdate_Month_ID" >
<option value="1" <?=(date('n')==1?'selected':'')?>>Jan</option>
<option value="2" <?=(date('n')==2?'selected':'')?>>Feb</option>
<option value="3" <?=(date('n')==3?'selected':'')?>>Mar</option>
<option value="4" <?=(date('n')==4?'selected':'')?>>Apr</option>
<option value="5" <?=(date('n')==5?'selected':'')?>>May</option>
<option value="6" <?=(date('n')==6?'selected':'')?>>Jun</option>
<option value="7" <?=(date('n')==7?'selected':'')?>>Jul</option>
<option value="8" <?=(date('n')==8?'selected':'')?>>Aug</option>
<option value="9" <?=(date('n')==9?'selected':'')?>>Sep</option>
<option value="10" <?=(date('n')==10?'selected':'')?>>Oct</option>
<option value="11" <?=(date('n')==11?'selected':'')?>>Nov</option>
<option value="12" <?=(date('n')==12?'selected':'')?>>Dec</option>
</select>
<select class="Calendar" id="cdate_Day_ID" >
<option <?=(date('d')==1?'selected':'')?>>1</option>
<option <?=(date('d')==2?'selected':'')?>>2</option>
<option <?=(date('d')==3?'selected':'')?>>3</option>
<option <?=(date('d')==4?'selected':'')?>>4</option>
<option <?=(date('d')==5?'selected':'')?>>5</option>
<option <?=(date('d')==6?'selected':'')?>>6</option>
<option <?=(date('d')==7?'selected':'')?>>7</option>
<option <?=(date('d')==8?'selected':'')?>>8</option>
<option <?=(date('d')==9?'selected':'')?>>9</option>
<option <?=(date('d')==10?'selected':'')?>>10</option>
<option <?=(date('d')==11?'selected':'')?>>11</option>
<option <?=(date('d')==12?'selected':'')?>>12</option>
<option <?=(date('d')==13?'selected':'')?>">13</option>
<option <?=(date('d')==14?'selected':'')?>>14</option>
<option <?=(date('d')==15?'selected':'')?>>15</option>
<option <?=(date('d')==16?'selected':'')?>>16</option>
<option <?=(date('d')==17?'selected':'')?>>17</option>
<option <?=(date('d')==18?'selected':'')?>>18</option>
<option <?=(date('d')==19?'selected':'')?>>19</option>
<option <?=(date('d')==20?'selected':'')?>>20</option>
<option <?=(date('d')==21?'selected':'')?>>21</option>
<option <?=(date('d')==22?'selected':'')?>>22</option>
<option <?=(date('d')==23?'selected':'')?>>23</option>
<option <?=(date('d')==24?'selected':'')?>>24</option>
<option <?=(date('d')==25?'selected':'')?>>25</option>
<option <?=(date('d')==26?'selected':'')?>>26</option>
<option <?=(date('d')==27?'selected':'')?>>27</option>
<option <?=(date('d')==28?'selected':'')?>>28</option>
<option <?=(date('d')==29?'selected':'')?>>29</option>
<option <?=(date('d')==30?'selected':'')?>>30</option>
<option <?=(date('d')==31?'selected':'')?>>31</option>
</select>
<input class="Calendar" type="text" size="4" maxlength="4" title="Year" value="<?=date('Y'?>">
The very first field named Forte ID posts a value of 0 no matter what selection I choose. Here are my two files:
Index.php(Form)
</head>
<h1> Customer Service Log Form </h1>
<form method="post" action="insert.php">
<table width="625" border="0">
<tr>
<td> Forte ID:</td>
<td><select id="ForteID" name="ForteID">
<option value="0">Select Your ID</option>
<option value="as7326">as7326</option>
<option value="aw8743">aw8743</option>
<option value="bj0920">bj0920</option>
<option value="bs1441">bs1441</option>
<option value="dk7017">dk7017</option>
<option value="dl7686">dl7686</option>
<option value="dm2940">dm2940</option>
<option value="jn2468">jn2468</option>
<option value="jw9598">jw9598</option>
<option value="kp4945">kp4945</option>
<option value="nl2589">nl2589</option>
<option value="rp7021">rp7021</option>
<option value="sh1346">sh1346</option>
</select></td>
</tr>
<tr>
<td> Disposition</td>
<td><select id="disposition" name="disposition">
<option value="0">Select a Disposition</option>
<option value="Save">Save</option>
<option value="Sale">Sale</option>
<option value="LOC">LOC</option>
<option value="Backout">Backout</option>
<option value="Revision">Revision</option>
<option value="Revision">Revision/Save</option>
</select>
</td>
</tr>
</table>
<hr />
<br />
<table width="400" border="0">
<tr>
<td>App Number:</td>
<td></td>
<td><input name="appnumber" type="text" required="required"></td>
</tr>
<tr>
<td>Finance Number:</td>
<td></td>
<td><input type="text" name = "Finance_Num"></td>
</tr>
<tr>
<td>Phone Number:</td>
<td></td>
<td><input type="text" name = "Phone_Num"></td>
</tr>
<tr>
<td># of Payments Collected:</td>
<td></td>
<td><input type="text" name = "num_payments"></td>
</tr>
<tr>
<td>ACH/CC</td>
<td></td>
<td><select id="ForteID" name="ForteID">
<option value="0">Select Payment</option>
<option value="ach">Checking</option>
<option value="cc">Credit Card</option>
</select></td>
</tr>
<tr>
<td>Date:</td>
<td></td>
<td><input name = "date" type="text" id="datepicker" autocomplete="off" required="required"></td>
</tr>
</table>
<br />
Notes:
<br />
<textarea name="notes" id="notes" cols="45" rows="5"></textarea>
</fieldset>
<hr />
<input type="Submit" name="formSubmit" value="Submit">
<input type="Reset" name="formReset" value="Reset">
<input type="button" value="View Logs" onClick="window.location.href='logs.php';">
</form>
</head>
Insert.php (PHP file to insert data from form into SQL Server Database):
$serverName = 'Server\SQLEXPRESS';
$connectionInfo = array('Database'=>'database', 'UID'=>'username', 'PWD'=>'password');
$connection = sqlsrv_connect($serverName, $connectionInfo);
if( $connection === false )
{
echo "Connection could not be established.\n";
die( print_r( sqlsrv_errors(), true));
}
$tsql = "INSERT INTO logs(ForteID, disposition, appnumber, Finance_Num, num_payments, ach_cc, date, notes, Phone_Num) VALUES (?,?,?,?,?,?,?,?,?)";
$parameters = array( $_POST[ForteID], $_POST[disposition], $_POST[appnumber], $_POST[Finance_Num], $_POST[num_payments], $_POST[ach_cc], $_POST[date], $_POST[notes], $_POST[Phone_Num]);
$stmt = sqlsrv_query($connection, $tsql, $parameters);
if( $stmt === false ){
echo "Statement could not be executed.\n";
die( print_r( sqlsrv_errors(), true));
} else {
echo "Rows affected: ".sqlsrv_rows_affected( $stmt )."\n";
}
No matter what option is selected in the index.php field Forte ID, it posts a value of 0. What is wrong. It was working before I added a field named Phone Number. But doesnt make sense why that would screw up the selections.
Let me know if I need to clarify anything and thanks for the help in advance!
You have to fields called ForteID
<select id="ForteID" name="ForteID">
<option value="0">Select Payment</option>
<option value="ach">Checking</option>
<option value="cc">Credit Card</option>
is the 2nd one
I am working on a certain form that accepts multiple values using checkbox and I find it hard to get all the values of the checked boxes and store them into the database.
Everytime my insertion query is being executed.. the only value that is stored in the database is the last checkbox the user selects thus ignoring the others..
here's my code:
----form-----------------------------------------------------------------'
<form name="addRes" method="post" action="addReservation_code.php">
<table>
<tr><td>Activity Date:</td>
<td><select name="month">
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value"December">December</option>
</select>
<select name="day">
<?php for($ctr=1;$ctr<=31;$ctr++){ ?>
<option value="<?php print($ctr); ?>"><?php print($ctr); ?></option>
<?php } ?>
</select> -
<select name="day2">
<?php for($ctr=1;$ctr<=31;$ctr++){ ?>
<option value="<?php print($ctr); ?>"><?php print($ctr); ?></option>
<?php } ?>
</select>
<input type="text" name="year"/></td>
</tr>
<tr><td>Activity Name:</td><td><input type="text" name="act_name" /></td></tr>
<tr><td>Activity Time:</td><td><input type="text" name="act_time" /></td></tr>
<tr><td>Room:</td>
<td>
<select name="room">
<?php
include 'RRSdbconnect.php';
$query = "SELECT room_name from room";
$result=mysql_query($query) or die('Invalid query'.mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_BOTH))
{
echo "<option>$row[room_name]";
}
?>
</option>
</select>
</td>
</tr>
<tr>
<td>Resources Needed:</td>
<td><input type="checkbox" name="resources" value="cpu" />CPU<br />
<input type="checkbox" name="resources" value="lcd" />LCD<br />
<input type="checkbox" name="resources" value="sounds" />Sounds<br />
<input type="checkbox" name="resources" value="sounds" />Others, Pls. specify<input type="text" name="others" /></td>
</tr>
<tr><td>No. of Person</td><td><input type="text" name="noOfPerson"/></td></tr>
<tr><td>Reserved by:</td><td><input type="text" name="reservedby" /></td></tr>
<tr><td></td></tr>
<tr><td><input type="submit" name="submit" value="Submit"/><input type="reset" name="clear" value="Clear"/></td></tr>
</table>
</form>
------------action code----------------------------------------------------
<?php
include 'RRSdbconnect.php';
session_start();
$date = $_POST['month'] . ' ' .$_POST['day']. '-' .$_POST['day2']. ', ' . $_POST['year'] ;
$name=$_POST['act_name'];
$time=$_POST['act_time'];
$room=$_POST['room'];
$resources=$_POST['resources'];
$noOfPerson=$_POST['noOfPerson'];
$reservedby=$_POST['reservedby'];
//insertions for add reservations
$query="insert into reservation (activity_date, activity_name, activity_time, room, resources_needed, no_person, reserved_by) values('$date','$name','$time','$room','$resources','$noOfPerson','$reservedby')";
$result=mysql_query($query,$link) or die("Error!".mysql_error());
?>
PS.
I am using checkbox on the column resources needed..
any help will be appreciate..tnx
If you change the name attribute of the checkbox to name="resources[]" you should get an array in the $_POST['resources']
Once you have the array in $_POST['resources']you can store/retrieve it in the database how you like. For example either as a string using implode() / explode() or serialize() / unserialize().