Results 1 to 3 of 3

Thread: Crud table

  1. #1
    dreamworker.de Beginner
    Join Date
    01/2017
    Posts
    2

    Crud table

    Hallo , ich habe eine Crud Tabelle mit einer Anbindung an eine MySQL Datenbank erstellt. Das funktioniert soweit ganz gut. Nur das update macht mir Probleme. Die Form zur Änderung der Daten befindt sich, wie die Tabelle, auf der Index Seite. Die Daten werden in das Änderungsformular geladen nur das Datensatz aktualisieren funktioniert nicht. Also sobald ich den Button Datensatz aktualisieren anclicke passiert nichts. Hat jemand von euch eine Idee woran das liegen kann

  2. #2
    dreamworker.de Administrator
    Join Date
    11/1999
    Location
    München, Kassel (GER)
    Posts
    1.359

    Re: Crud table

    Ein Bild vom Quelltext oder der Quelltext in eine Posting mit
    Code:
    CODE-Tag
    gepostet, sollte hilfreich. Bitte darauf achten keine Datenbankkennwörter, etc. zu posten. Auch wenn diese meist als DB_Connections inkludiert sind und in einer anderen Datei sind.
    Gruss Kai

  3. #3
    dreamworker.de Beginner
    Join Date
    01/2017
    Posts
    2

    Re: Crud table

    Anzeigen:
    Webhosting ab 3,99 €
    Hallo Kai,
    das oben beschriebene Problem habe ich gelöst aber ich habe da noch ein weiteres.
    Ich möchte die add - Form im Modal anzeigen lassen. Da komme ich leider nicht weiter.

    Code:
    <?php require_once('Connections/wrd.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      }
    
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
    
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
    }
    
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
    
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE plan SET Abteilung=%s, Bereich=%s WHERE id=%s",
                           GetSQLValueString($_POST['Abteilung'], "text"),
                           GetSQLValueString($_POST['Bereich'], "text"),
                           GetSQLValueString($_POST['id'], "int"));
    
      mysql_select_db($database_wrd, $wrd);
      $Result1 = mysql_query($updateSQL, $wrd) or die(mysql_error());
    }
    
    $maxRows_Recordset1 = 10;
    $pageNum_Recordset1 = 0;
    if (isset($_GET['pageNum_Recordset1'])) {
      $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
    }
    $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
    
    mysql_select_db($database_wrd, $wrd);
    $query_Recordset1 = "SELECT * FROM plan";
    $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
    $Recordset1 = mysql_query($query_limit_Recordset1, $wrd) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    
    if (isset($_GET['totalRows_Recordset1'])) {
      $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
    } else {
      $all_Recordset1 = mysql_query($query_Recordset1);
      $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
    }
    $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
    
    $colname_Edit = "-1";
    if (isset($_GET['id'])) {
      $colname_Edit = $_GET['id'];
    }
    mysql_select_db($database_wrd, $wrd);
    $query_Edit = sprintf("SELECT * FROM plan WHERE id = %s", GetSQLValueString($colname_Edit, "int"));
    $Edit = mysql_query($query_Edit, $wrd) or die(mysql_error());
    $row_Edit = mysql_fetch_assoc($Edit);
    $totalRows_Edit = mysql_num_rows($Edit);
    ?>
    
    <!DOCTYPE html>
    <html lang="en"><head>
    
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="">
        <meta name="author" content="">
    
      
        <!-- Bootstrap Core CSS -->
        <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    
        <!-- MetisMenu CSS -->
        <link href="vendor/metisMenu/metisMenu.min.css" rel="stylesheet">
    
        <!-- DataTables CSS -->
        <link href="vendor/datatables-plugins/dataTables.bootstrap.css" rel="stylesheet">
    
        <!-- DataTables Responsive CSS -->
        <link href="vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">
    
        <!-- Custom CSS -->
        <link href="dist/css/sb-admin-2.css" rel="stylesheet">
    
        <!-- Custom Fonts -->
        <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
        
    
       
    </head>
    
    <body>
    
       
                            </div>
                            <!-- /.panel-heading -->
                            <div class="panel-body">
                              <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                                 <thead>
                                 <tr>
                                  <td>id</td>
                                  <td>Abteilung</td>
                                  <td>Bereich</td>
                                  <td>update</td>
                                 </tr>
                                </thead>
                                    <tbody>
                                <?php do { ?>
                                  <tr>
                                    <td><?php echo $row_Recordset1['id']; ?></td>
                                    <td><?php echo $row_Recordset1['Abteilung']; ?></td>
                                    <td><?php echo $row_Recordset1['Bereich']; ?></td>
                                    <td> <a href="?id=<?php echo $row_Recordset1['id']; ?>">
                                      <button type="button" class="btn btn-info btn-lg" id="myBtn">Open Modal</button>
                                    </a></td>
                                  </tr>
                                  <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
                              </table>
    <!-- /.table-responsive --><!-- Modal --></div>
                            <!-- /.panel-body -->
                        </div>
                        <!-- /.panel -->
                    </div>
                    <!-- /.col-lg-12 -->
                </div>
                <!-- /.row -->
                <div class="row"><!-- /.col-lg-6 --><!-- /.col-lg-6 -->
                </div
      
    
    
               ><div class="container">
      
    
    
      <!-- Modal -->
      <div class="modal fade" id="myModal" role="dialog">
        <div class="modal-dialog">
        
          <!-- Modal content-->
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title">Modal Header</h4>
            </div>
            <div class="modal-body">
                        <form action="<?php echo $editFormAction; ?>" method="post" name="add" id="add">
                  <table align="center">
                    <tr valign="baseline">
                      <td nowrap align="right">Id:</td>
                      <td><?php echo $row_Edit['id']; ?></td>
                    </tr>
                    <tr valign="baseline">
                      <td nowrap align="right">Abteilung:</td>
                      <td><input type="text" name="Abteilung" value="<?php echo htmlentities($row_Edit['Abteilung'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
                    </tr>
                    <tr valign="baseline">
                      <td nowrap align="right">Bereich:</td>
                      <td><input type="text" name="Bereich" value="<?php echo htmlentities($row_Edit['Bereich'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
                    </tr>
                    <tr valign="baseline">
                      <td nowrap align="right">&nbsp;</td>
                      <td><input type="submit" value="Datensatz aktualisieren"></td>
                    </tr>
                  </table>
                  <input type="hidden" name="MM_update" value="form1">
                  <input type="hidden" name="id" value="<?php echo $row_Edit['id']; ?>">
                </form>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
          </div>
          
          
        </div>
      </div>
      
    </div> 
                
    <!-- jQuery -->
    <script src="vendor/jquery/jquery.min.js"></script>
    
        <!-- Bootstrap Core JavaScript -->
    <script src="vendor/bootstrap/js/bootstrap.min.js"></script>
    
        <!-- Metis Menu Plugin JavaScript -->
    <script src="vendor/metisMenu/metisMenu.min.js"></script>
    
        <!-- DataTables JavaScript -->
    <script src="vendor/datatables/js/jquery.dataTables.min.js"></script>
    <script src="vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
    <script src="vendor/datatables-responsive/dataTables.responsive.js"></script>
    
    <script>
        $(document).ready(function() {
            $('#dataTables-example').DataTable({
                responsive: true
            });
        });
        </script>
    
    <script>
    $(document).ready(function(){
        $("#myBtn").click(function(){
            $("#myModal").modal();
        });
    });
    </script>
    
    
    </div>
    </body>
    
    </html>
    <?php
    mysql_free_result($Recordset1);
    
    mysql_free_result($Edit);
    ?>

Similar Threads

  1. Anfänger: Table
    By Salida in forum Adobe Dreamweaver
    Replies: 2
    Last Post: 08.12.2006, 19:54
  2. Replies: 3
    Last Post: 26.03.2006, 12:40
  3. Layout: Table in Table im NE 4.73 (Win)
    By GeoS in forum Adobe Dreamweaver
    Replies: 0
    Last Post: 23.09.2002, 23:15
  4. Layout: table in table background
    By quasili in forum Adobe Dreamweaver
    Replies: 4
    Last Post: 23.05.2002, 15:09
  5. Time Table
    By joinmark in forum Adobe Flash & OpenSWF
    Replies: 0
    Last Post: 19.09.2001, 10:19

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •