faces3 Posted May 1, 2013 Share Posted May 1, 2013 Hey! I work for add/remove input field and mysql. But im newbie and little bit problems with it. I want all field data save new row. Here is script. <html> <head> <title>Silmaring</title> <meta name="description" content="Silmaring"> <meta name="author" content="Silmaring"> <STYLE type="text/css"> #ained { position:absolute; margin-top:40px; } #ope { position:absolute; margin-top:40px; margin-left:200px; } #lisa { position:absolute; margin-top:500px; } </STYLE> </head> <body> <form action= "" method="post" enctype="multipart/form-data"> <H2>Registeeri uus kool</h2> Koolinimi: <input type="text" name = "kool" size="15" /></br> <div id="ained"> Ained:</br> <input type="text" name="aine" id="aine"><br> <input type="text" name="aine" id="aine"><br> </div> <div id="ope"> Õpetajad: <input type="text" name="ope" id="ope"><br> <input type="text" name="ope" id="ope"><br> </div> <div id="lisa"> </br><input type="submit" value="Lisa kool" /> </div> </form> </body> </html> <?php error_reporting(E_ALL ^ E_NOTICE); $kool = $_REQUEST['kool']; $aine = $_REQUEST['aine']; $ope = $_REQUEST['ope']; // MySQL uhendus $user="root"; $password=""; $database="silmaring"; $con="localhost"; mysql_connect($con,$user,$password); @mysql_select_db($database) or die( "Unable to select database"); mysql_query("CREATE TABLE $kool(id int(6) NOT NULL auto_increment,aine varchar(50) NOT NULL,opetaja varchar(50) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))"); mysql_query("INSERT INTO $kool(aine,opetaja) VALUES ('$ope','$ope')"); mysql_query("INSERT INTO $kool(aine,opetaja) VALUES ('$ope','$ope')"); mysql_close(); ?> Quote Link to comment Share on other sites More sharing options...
trq Posted May 1, 2013 Share Posted May 1, 2013 We are going to need a much clearer explanation. Quote Link to comment Share on other sites More sharing options...
oaass Posted May 1, 2013 Share Posted May 1, 2013 Please post any error messages and some debug information Quote Link to comment Share on other sites More sharing options...
faces3 Posted May 1, 2013 Author Share Posted May 1, 2013 I need have only one line input field. and have button "add new input line in form" And then open new line and there is two input field. And all input field line save new row in database. Quote Link to comment Share on other sites More sharing options...
faces3 Posted May 1, 2013 Author Share Posted May 1, 2013 Just like here, but open two input fields and how to save it database new row. Quote Link to comment Share on other sites More sharing options...
faces3 Posted May 1, 2013 Author Share Posted May 1, 2013 http://demo.blogaddition.com/dynamic_textbox/ Quote Link to comment Share on other sites More sharing options...
trq Posted May 1, 2013 Share Posted May 1, 2013 That is better done with javascript. Just make new elements named aine[] and ope[] (not that one mistake you currently have already is that id's in html must be unique). This will create an array of form fields which you can then simply loop through in php. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.