Using implode function to insert into database |
[eluser]itz4mesays[/eluser]
Please i need someone to put me through on how to use the implode function in storing array values into the database.
[eluser]Ckirk[/eluser]
or is itz4mesays saying that he wants to store an array into a single field? If that's the case you could either preserve the array with: Code: $yourField = serialize($yourArray); or if you prefer json Code: $yourField = json_encode($yourArray);
[eluser]itz4mesays[/eluser]
@ckirk, below is what i am trying to achieve View echo form_open('admin/add_courses');?> <table border="0" cellspacing="2" cellpadding="0"> <tr> <th>Course Code</th> <th>Course Title</th> <th>Course Unit</th> <th>Course Status</th> <th>Level</th> <th>Semester</th> </tr> <?php for($i=0; $i<3; $i++){?> <tr> <td><input type="text" name="course_code" value=""></td> <td><input type="text" name="course_title" value=""><br></td> <td> <select name="course_unit"> <option value="">Select course unit</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">4</option> </select> </td> <td> <select name="course_status"> <option value="">Select course status</option> <option value="E">Elective</option> <option value="C">Core</option> </select> </td> <td> <select name="level"> <option value="">Select level</option> <option value="100">100</option> <option value="200">200</option> <option value="300">300</option> <option value="400">400</option> <option value="500">500</option> <option value="600">600</option> </select> </td> <td> <select name="semester"> <option value="">Select semester</option> <option value="First Semester">1st</option> <option value="Second Semester">2nd</option> </select> </td> </tr> <?php } echo '</table>'; echo form_submit('btnsubmit', 'Add Course(s)'); echo form_close(); ?> Looking for a way to insert multiple rows into the database. Any help?
[eluser]xtremer360[/eluser]
This is what I found directly from the link that was provided to you. Code: $this->db->insert_batch();
[eluser]itz4mesays[/eluser]
I guess this will only work if am dealing with constant values. I am getting values from the users, so it varies. well, lemme give it a try..Thanks....Any other idea will be welcomed. |
Welcome Guest, Not a member yet? Register Sign In |