Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- mysql_connect("localhost","root");
- mysql_select_db("testdb");
- ?>
- <style>
- a {
- text-decoration: none;
- }
- ul {
- text-align: center;
- overflow: auto;
- width: 100%;
- }
- li {
- float: left;
- width: 31%;
- background-color: transparent;
- border: 1px white solid;
- display: inline;
- font-size: 200%;
- padding: 10px;
- list-style-type: none;
- }
- input, textarea, button, select, option {
- float: left;
- margin-top: 20px;
- background-color: transparent;
- color: white;
- font-size: 150%;
- width: 96.5%;
- border: 1px white solid;
- outline: none;
- }
- option {
- background-color: #104378;
- }
- input[type="submit"], button{
- width: 100px;
- padding: 10px;
- }
- </style>
- <script>
- $(function() {
- $( "#tabs" ).tabs();
- });
- $(document).ready(function(){
- $("button#eins").click(function(){
- $("div#table").html($("div#table").html()+"<input type='text' name='arrayname[]'>");
- });
- $("button#zwei").click(function(){
- if($("div#table input:last-child").val() == "ID"){
- } else {
- $("div#table input:last-child").remove();
- }
- });
- $('select').on('change', function(){
- $.get("reader.php?type=getColumns&tabelle="+$(this).val(), function(data){
- $("div#selectGoto").html(data);
- });
- });
- });
- </script>
- <div id="tabs">
- <ul>
- <li><a href="#tabs-1">Übersicht</a></li>
- <li><a href="#tabs-2">Projekt Erstellen</a></li>
- <li><a href="#tabs-3">Datensatz zu Projekt Erstellen</a></li>
- <div id="tabs-1">
- </div>
- <div id="tabs-2">
- <form action="add.php" method="post">
- <input type="text" name="projektName" placeholder="Projekt Name" autocomplete="off">
- <input type="text" name="projektbezeichnung" placeholder="Projekt Name (nur a-z,A-Z,0-9)" autocomplete="off">
- <textarea name="anmerkung" placeholder="Anmerkung..."></textarea>
- <div id="table">
- <input type="text" name="table" value="ID" disabled="true">
- </div>
- <input type="submit" name="submit_projekt">
- </form><button id="eins">+</button><button id="zwei">-</button>
- </div>
- <div id="tabs-3">
- <form action="add.php" method="post">
- <select>
- <?php
- $result = mysql_query("show tables");
- echo "<option>Wähle ein Projekt aus</option>";
- while($table = mysql_fetch_array($result)) {
- echo "<option>".$table[0]."</option>";
- }
- ?>
- </select>
- <div id="selectGoto"></div>
- <input type="submit" name="submit_entry">
- </form>
- </div>
- </div>
- <div id="fenster"></div>
- <?php
- if(isset($_POST['submit_projekt'])){
- $projektName = $_POST['projektName'];
- $projektbezeichnung = $_POST['projektbezeichnung'];
- $projektAnmerkung = $_POST['anmerkung'];
- $datum = date("d.m.Y");
- $zeit = date("H:i:s");
- $ip = $_SERVER['REMOTE_ADDR'];
- $checkAvail = mysql_query("SELECT * FROM projekte where projekt like '$projektName'");
- if(mysql_num_rows($checkAvail) == 0){
- if(strlen($projektName) > 3){
- mysql_query("INSERT INTO projekte (projekt, bezeichnung, datum,zeit,ip,anmerkung) VALUES ('$projektName','$projektbezeichnung','$datum','$zeit','$ip','$projektAnmerkung')");
- mysql_query("CREATE TABLE `$projektbezeichnung` (`id` int(11) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
- mysql_query("ALTER TABLE `$projektbezeichnung` ADD PRIMARY KEY (`id`);");
- mysql_query("ALTER TABLE `$projektbezeichnung` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;");
- $array = $_POST['arrayname'];
- $count = count($array);
- $i = 0;
- while($i < $count){
- $reihe = $array[$i];
- mysql_query("ALTER TABLE `$projektbezeichnung` ADD `$reihe` TEXT NOT NULL FIRST;");
- $i++;
- }
- }
- }
- Header('location: index.php');
- }
- if(isset($_POST['submit_entry'])){
- $allfields = $_POST['allFields'];
- $tableName = $_POST['tableName'];
- $explode = explode(",",$allfields);
- $count = count($explode);
- $i = 0;
- $sql = "(";
- while($i < $count){
- $sql = $sql.$explode[$i].",";
- $i++;
- }
- $sql = substr_replace($sql, "", -2);
- $sql = $sql.") VALUES (";
- $ii = 0;
- while($ii < $count){
- $explode = explode(",",$allfields);
- $var = $explode[$ii];
- $var2 = $_POST[$var];
- //array_search($ii, $_POST);
- $sql = $sql."'".$var2."'";
- $ii++;
- }
- $sql = $sql.")";
- echo $sql;
- mysql_query("INSERT INTO `$tableName` $sql");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement