Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i create the code for text box, date and drop down within for loop and try to store those values in my DB using array concept. i search some code for internet and but not working good for storing data. I'm a newbie to PHP. Any idea would be great.

<?php                       
for($i=1;$i<=4;$i++)
{
?>
<tr>
                        <td>Name</td>
                        <td><input type="text" name="col_name[<?php echo $i;?>]" value=""/></td>
</tr>
<tr>
<td >Complete Address (Road Name, City, State, Country, Zip)</td>
<td><textarea name="add[<?php echo $i;?>]" value=""></textarea></td>
</tr>
<td> Date of birth(Ex.: mm-dd-yyyy)</td>
<td><input type="text" name="dob[<?php echo $i;?>]" id="dob<?php echo $i ;?>" value=""/>   
</tr>
<tr>
<td>Sex</td>
<td><input type="radio" name="col_certi[<?php echo $i;?>]" value="Yes"/>&nbsp;&nbsp;Yes&nbsp;
<input type="radio" name="col_certi[<?php echo $i;?>]" value="No"/>&nbsp;No
</td>
<tr>
<td >Country</td>
<td><select name="countryid[<?php echo $i;?>]"/>
<option value="">Select</option>
</select>
</td>
</tr>
<tr>
<td>File Upload</td>
<td><input type="file" name="col_certi_file[<?php echo $i;?>]" value="<?php echo $fir_col_certi_file;?>"/></td>
</tr>
<tr><td align="center" colspan="4"><hr color="#6699CC" width="90%"/></td></tr>
<?php
}
?>

and i write the code for save the col_name data only using php

foreach($col_name as $colname)
$updatecol="update education set col_name='$colname' where employee_id=".$ employee_id;
if(!mysql_query($updatecol))

here the $colname last value only store in the database.. i want to store 4 value in database.. how to do it.

share|improve this question
1  
Where is your code????? – Deepu Apr 23 at 5:42
@raj_as: your posting shows there is no background work you have done before posting the question. – Mahesh.D Apr 23 at 5:55

1 Answer

You can use for loop for inserting into DB some thing like this

for($i=0;$i<5;$i++) {

insert query

}

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.