<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("db_name",$con);
if($POST["Submit"]=='Submit')
{$comments=$POST["comm"];
$row=$_POST["file"];
$result=implode(",",$row);
$sql=mysql_query("insert into tablename(fieldname)VALUES('$result','$comments')");
}
?>
<html>
<script language="JavaScript">
var glob;
glob = 1;
function insert_row(tablename)
{
var the_table = document.getElementById(tablename);
var new_row_index = the_table.rows.length;
glob = glob + 1;
the_table.insertRow(new_row_index);
the_table.rows[new_row_index].insertCell(0);
the_table.rows[new_row_index].cells[0].innerHTML =(the_table.rows[0].innerHTML);
}
function removeRowFromTable(tblSample)
{
var tbl = document.getElementById(tblSample);
var lastRow = tbl.rows.length;
if (lastRow > 1) tbl.deleteRow(lastRow - 1);
}
function removeRowFromTable(tblSample)
{
var tbl = document.getElementById(tblSample);
var lastRow = tbl.rows.length;
if (lastRow > 1) tbl.deleteRow(lastRow - 1);
}
function validateRow(frm)
{
var chkb = document.getElementById('chkValidate');
if (chkb.checked) {
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length - 1;
var i;
for (i=1; i<=lastRow; i++) {
var aRow = document.getElementById('txtRow' + i);
if (aRow.value.length <= 0) {
alert('Row ' + i + ' is empty');
return false;
}
}
}
openInNewWindow(frm);
}
</script>
<body bgcolor="#009900">
<form action="index.php" method="post" onSubmit=" return validateRow(this.form);" >
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="maintxt" id="product">
<tr>
<td >Text Field: <span style="color:red">*</span><br />
<input name="file[]" type="text" class="Textfield" id="prod_image[]" size="42" style="border:1px solid #c2c2c2"/></td>
</tr>
<tr>
<td height="24" colspan="2" align="right" ><input name="increment" type="button" class="mtxt" id="increment" onClick="insert_row('product')" value="Add"/>
<input name="decrement" type="button" class="mtxt" id="decrement" onClick="removeRowFromTable('product')" value="Remove"/></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
</table>
<p> Comments:
<input type="text" name="comm">
</p>
<p>
<input type="submit" value="Submit" name="Submit" />
</p>
</form>
</body>
</html>