---------------------------------
The Problem
---------------------------------

I have made the following structure which uses Dynamic Object Module (DOM) to
add/remove a field on the page which works perfectly fine.

I have a database whose structure contains tag,date and ip as field.

Now I want to send whatever data has been written on the tags field to be
stored in the database in the tag field of the db.

I read on a forum to use implode function or serialze function and then post
the data (which is combined) to the database.

I didnot understand how to use the implode function WITH REFERENCE TO THE GIVEN TASK.

I am storing whatever the contatenated data from all the tags fields (the no. depends
on the click on add button) in a variable 'tag'

And I want all the individual data of the field using DOM in variable tagarray.

Please tell me what will be relationship between the tag and arraytag so all the
array of tags field are concatenated and stored in tag variable.

How do I define the index of tag array and the the variable tag.
---------------------------------
contents of story.php
---------------------------------

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("mysql", $con);
mysql_close($con);
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add/Remove child: Javascript</title>
<script type="text/javascript">
<!--

function insertRowPHP()
{
var tbl = document.getElementById('tblInsertRowPHP');
var iteration = tbl.tBodies[0].rows.length+1;
newRow = tbl.tBodies[0].insertRow(-1);
var newCell = newRow.insertCell(0);
newCell.innerHTML = 'tag ' + iteration;
var newCell1 = newRow.insertCell(1);
var el = document.createElement('input');
el.type = 'text';
el.name = 'tag[]';
el.id = 'tag' + iteration;
el.size = 15;
newCell1.appendChild(el);
}

function deleteRows(tblId)
{
var tbl = document.getElementById(tblId);
var i=tbl.tBodies[0].rows.length-1; {
tbl.tBodies[0].deleteRow(i);
}
}</script>
</head>

<body>

<form action="storyinsert.php" method="post">

<a name="tag" onClick="insertRowPHP();" href="#">Add Tag</a>
<a name="tag" onClick="deleteRows('tblInsertRowPHP');" href="#">Remove Tag</a><br>

<table border="0" cellspacing="0" id="tblInsertRowPHP">
<thead>
<tr>
<th colspan="2">tblInsertRowPHP header</th>

</tr>
</thead>
<tbody></tbody>
</table>

<?php
--------------------------------------------------------
$tag = addslashes(serialize($arraytag)); // problem area

what should be the relation between tag and tagarray
and how should the index of tag array and initialization
of tag variable be done. Where and with what should I
define the tag array and the tag variable?
--------------------------------------------------------
?>
<input type="submit" />
<?php
$date = mktime(date("G"), date("i"), date("s"), date("m"), date("d"), date("Y"));
echo date("d/m/Y G:i:s", $date);
?>
<input type="hidden" name="date" value="<?php echo date("d/m/Y", $date);?>" />
<input type="hidden" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR'];?>" />
</form>
</body>
</html>

---------------------------------
contents of storyinsert.php
---------------------------------


<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("mysql", $con);

$sql="INSERT INTO story (tag, date,ip) // fields in the db//
VALUES
('$_POST[tag]','$_POST[date]','$_POST[ip]')";

/*the tag should cantain concatenated elements which
have been filled in the form which comes up dynamically
on pressing add button */

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}

echo "Article added on ";
echo date('l dS F Y h:i:s A');
echo " from ";
echo $_SERVER['REMOTE_ADDR'];

mysql_close($con)
?>