![]() |
Can someone help explain multiple insert?
I've got a problem sorting out an insert that cycles through multiple rows of a form, and then constructs and executes the insert. I've Googled 'mysql php insert multiple rows form', and while there's a quite a few articles, none of them seem particularly well commented or explained, so I'm hoping someone can shed light on my confusion.
I have a database table called mailinglist which holds data about which people get invited to specific events for a client of mine. It has five columns - mailinglistID (the primary key) mailnglistnameID, locationID and clientID (foreign keys) and isCard (a boolean). I found some sample code at Object Mix, which I used as the basis of my attempt, after cleaning up the HTML. My form HTML is: Code:
<!DOCTYPE html>PHP Code:
I've been looking at this since first thing yesterday, and I'm just going round in circles now. If anyone could point out where I'm going wrong, I'd be grateful. |
Okay - thought I'd try answering my own question about the repeated [] making the ids invalid and put numbers in there, which I can insert on my final from using a loop at run-time. So now my test form looks like this:
Code:
<!DOCTYPE html> |
use each array to save it. so, just get it one id to get all, and in each id, do insert.
PHP Code:
|
Thanks for being so helpful - that works perfectly. I'm trying to create a similar multiple update, using that as a template and have ended up with
PHP Code:
|
You don't need to read array in update vars,
PHP Code:
so, you have get it variable values and just need to update, no need to read each array again. second problem, to update multipel field, separated it with comma, no used "AND". PHP Code:
|
Thanks - and thanks for the commenting in the code. I guess I've been spoiled having Dreamweaver write all the update and insert behaviours for me - I think it's probably time for me to buy a book and dig into the PHP properly! ;)
|
you are welcome
|
| All times are GMT +1. The time now is 09:16 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.