Jump to content

Add/remove input field & mysql


faces3

Recommended Posts

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();
?>

Link to comment
https://forums.phpfreaks.com/topic/277484-addremove-input-field-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.