Creating a dynamic form, but how to do the query?

前端 未结 3 1730
余生分开走
余生分开走 2020-12-21 21:34

I\'ve created a dynamic form which allows you to modify the amount of input fields you need. This is because they may have 15 band members and need 15 fields, or one band ma

3条回答
  •  滥情空心
    2020-12-21 22:22

    (This started out to be a comment, but it is too long .. )

    There are different ways to approach it. My preference is the one Travis mentioned in the comments. Basically have jquery store the total number of members in a hidden form field. Then use that value to loop through the member fields, validate the values, and insert as needed.

    You could easily adapt Dan or jamckinn's example to do this. Notice they are using to help guard against sql injection? Also, since these are related inserts you want to wrap the whole thing inside a single . That ensures the inserts are treated a single unit. Either they all succeed or they all fail - together.

        
    
        
            
            
    
            
            
                
                    INSERT INTO members ( members_name )
                    VALUES 
                    ( 
                        
                    )
                
            
       
    

提交回复
热议问题