Forum Moderators: open

Message Too Old, No Replies

how insert an array into mysql tables?.

please help!...

         

ace04

2:36 am on Feb 8, 2006 (gmt 0)

10+ Year Member



if i have a php code like this...

for($i=1; $i<$numdependent; $i++)
{
echo"
<tr>
<td width=1% align=center><h2>&nbsp;$i</td>
<td width=18% align=center><input type=text name=dname[$i] id='name[$i]' ></td>
<td width=7% align=center><input type=text name=dage[$i] id='dage[$i]' size=2></td>
<td width=20% align=center><input type =text name=dschool[$i] id='dschool[$i]'></td>
<td width=20% align=center><input type =text name=dyrlevel[$i] id='dyrlevel[$i]'></td>
</tr>";
}

ace04

3:35 am on Feb 8, 2006 (gmt 0)

10+ Year Member



can anybody help me about implode and explode..
i have inserted my data using implode and i have made use of
"-" as a sign... how can i view this?....

Dijkgraaf

10:28 pm on Feb 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well there are two ways to go about it.
In either case you will need to create a loop to step through the array to create the SQL statement(s)

Then you either insert then in at a time or you use

INSERT INTO tablename( field1, field2 )
SELECT "a", "b"
UNION
SELECT "c", "d"

where of course tablename is your table, field1 and field2 are the field names, and a,b,c,d are the values from your arrays that you want to insert.