![]() |
Multi insert from form data
Am a bit lost on how to get the data from a form and put it into a database (not update)
The mysql side easy enough.. Code:
insert into (col1, col2,col3) VALUES ($col1, $col2,$col3), ($col1, $col2,$col3). ($col1, $col2,$col3);So Multiple instances of col1, col2, col3 .. On Submit are they summitted as an array ? e.g Code:
<form id="form1" name="form1" method="post" action="<? $_SERVER['PHP_SELF']; ?>"> |
Ok, so I now know how to get the form data into arrays...
Code:
<body>Hmm... so have created a mutlidimentional array Code:
$new_array = array(($_REQUEST['col1']),($_REQUEST['col2']),($_REQUEST['col3'])); |
Now to show itterate though the array and show the data...
Code:
for ($i=0; $i < count($_REQUEST['col1']); $i++) { |
Time to build the sql ...
Code:
$sql = "INSERT INTO table(col1, col2, col3) VALUES ";Code:
echo substr($sql, 0, -1);And I think thats it about done.. Sorry for going on, but I thought I would ask the question, then figured out how to do it, I hope someone else gets some use out of this :-D P.S. Not tried it yet so don't know if it works ! |
| All times are GMT. The time now is 02:40 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0