Reputation: 1
i have this small project and its simple 1 data entry item code and date 2 read the date and edit later
thats it
now i want to make bulk add like big text area i add item number and go next line i add next code etc without , or anything just simple enter to go next line
now how to update the database to read each line alone and make new record for each line and add date also
ill show you
$txtitemcode=$_POST['itemcode'];
$date = date("Y-m-d");
$_POST['date'] = $date;
$sql="INSERT INTO dba(itemcode,date) VALUES ('".$txtitemcode."','".$date."')";
and this the main box
<html>
<body>
<form action=add.php method=POST>
<table border=0 align=center bgcolor="#99FF00">
<tr>
<td>ITEM CODE</td><td><textarea input type="text" rows="20" cols="50" name="itemcode" /></textarea></td></tr>
<tr><td colspan=2 align=center><input type=submit value=add><input type=reset value=cancel>
</table>
thank you
Upvotes: 0
Views: 1319
Reputation: 591
Okay use any special character to differentiate records in text area.. I am assuming you used "@" sign in textarea.... after each record you put @ sign...
Like:
121@131@141@125@111@111@100@007
PHP CODE WILL BE LIKE THIS THAN:
This is your form data you getting...
$txtitemcode= $_POST['itemcode'];
$date = date("Y-m-d");
$_POST['date'] = $date;
$dataexplode = explode("@",$txtitemcode);
foreach ($dataexplode as $multipledata)
{
$sql="INSERT INTO dba(itemcode,date) VALUES ('".$multipledata."','".$date."')";
}
Hope so this will work for you...
Upvotes: 1