I have error in tis code.any help will b appreciable.tanks in advance.
if(isset($_POST))
{
for($i=0;$i<count($_POST);$i++)
{
if(!empty($_POST["hdntxtRow".$i]))
{
echo $_POST["hdntxtRow".$i]."<br />";
}
}
$question=$_POST;
$choice1=$_POST;
$choice2=$_POST;
$choice3=$_POST;
$choice4=$_POST;
$choice5=$_POST;
$answer=$_POST;
$a=mysql_query("INSERT INTO question(questions,choice1,choice2,choice3,choice4,choice5,answer)
VALUES('$question','$choice1','$choice2','$choice3','$choice4','$choice5','$answer')");
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script>
function addRowToTable()
{
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// left cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);
// right cell
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.type = 'text';
el.name = 'txtRow' + iteration;
el.id = 'txtRow' + iteration;
el.size = 40;
cellRight.appendChild(el);
var elh = document.createElement('input');
elh.type = 'hidden';
elh.runat ='server'; //This need to check
elh.name = 'hdntxtRow1' + iteration;
elh.id = 'hndtxtRow1' + iteration;
cellRight.appendChild(elh);
var elhi = document.createElement('input');
elhi.type = 'hidden';
elhi.runat ='server'; //This need to check
elhi.name = 'hdntxtRow2' + iteration;
elhi.id = 'hndtxtRow2' + iteration;
cellRight.appendChild(elhi);
}
</script>
<BODY>
<form name="frmaddtxtbox" method="post" action="">
<div class="extraline" style="margin-left:620px;margin-top:105px;position:absolute;">
<input type="button" value="Add" onClick="addRowToTable();" />
Add one more choice
</div>
<table width="200" border="1" style="margin-left:300px">
<tr>
<td>Enter Question</td>
<td><input type="text" name="txtquestion" /></td>
</tr>
<tr>
<td>choice 1</td>
<td><input type="text" name="txtchoice1" /></td>
</tr>
<tr>
<td>choice 2</td>
<td><input type="text" name="txtchoice2" /></td>
</tr>
<tr>
<td>choice 3</td>
<td><input type="text" name="txtchoice3" /></td>
</tr>
<tr>
</tr>
<tr>
<td>1</td>
<td><input type="text" name="txtRow1"
id="txtRow1" size="40" /></td>
<td><input type="hidden" name="hdntxtRow1"
id="txtRow2" size="40" /></td>
<td><input type="hidden" name="hdntxtRow2"
id="txtRow3" size="40" /></td>
</tr>
<tr>
<td>Ans</td>
<td><input type="text" name="txtanswer" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="btnsave" value="Save" /></td>
</tr>
</table>
</form>
</body>
</html>