从未提交的数据

时间:2017-10-02 18:48:57

标签: php html web web-applications

HTML从数据未提交,甚至没有PHP页面被加载到表格所在的位置。  在下面的代码中,我使用了从表格的上方,我将在单击提交按钮后使用清单选择表格的行,但是当前的pade甚至没有加载以显示我甚至错误和空白页面本身。

<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title></title>

    <style media="screen">

    #listdiv1{
        position: relative;
        display:block;
        left:15%;
    }
    body{
        background-color: rgb(231, 187, 82);
    }
    th{
        font-variant: small-caps;
        font-weight: lighter;
        color:red;
    }
    </style>
</head>
<body >
<div id="listdiv1" style="background-
color:red;width:1400px;height:900px;position:relative;top:20px;">

  <div id="listDivIn2" style="background-color:blue;width:1400px;height:900px;display:inline-block;position: absolute;">
      <h1 style="margin-left:500px;font-family:Trebuchet MS;font-variant: small-caps;"> Customers List</h1>
    <div style="position:absolute;top:80px;margin-left:60px;">
    <label style="font-family:Trebuchet MS;color:rgb(187, 218, 177);">Customer_Name</label><input type="text" name="cn_tosearch" placeholder="enter name" style="position: absolute;width:300px;margin-left:14px" /></br>
    <label style="margin-left:30px;font-family:Trebuchet MS;color:rgb(187, 218, 177);">Date</label><input type="text" name="Date_tosearch" placeholder="enter date"  style="position: absolute;margin-left:68px;width:300px;"  /></div></br>
     <button type="button" class="btn btn-secondary" style="position:absolute;top:150px;left:280px;">Search</button>

    <div id="divtable" style="background-color:black;width:1200px;height:570px;position:absolute;top:220px;margin-left:90px;" >
      <table style="width:100%;position:absolute;color:red;margin-left:35px;top:10px;" >
      <?php
        $dbs=mysqli_connect("localhost","root","","biz_dairy")
        or die("connection error");
        $q="select * from add_customer";
        $result=mysqli_query($dbs,$q)
        or die("error in query");
        $data=mysqli_fetch_all($result);
         mysqli_close($dbs);
        $c=count($data);

       echo "<tr><th>date</th><th>name</th><th>fanme</th><th>gender</th><th>mob_no</th><th>email</th><th>address</th><th>balance</th></tr>";
       echo  '<form name="register"  method="POST" action="$_SERVER[\'PHP_SELF\']" >';

     for ($i = 0; $i <= $c-1; $i++)
     {
        echo '<input type="checkbox" name="delete[]" value="delete" style="position:relative;top:34px;left:6px;" /><tr>';
        echo '<td>'.$data[$i][0].'</td>';
        echo '<td>'.$data[$i][1].'</td>';
        echo '<td>'.$data[$i][2].'</td>';
        echo '<td>'.$data[$i][3].'</td>';
        echo '<td>'.$data[$i][4].'</td>';
        echo '<td>'.$data[$i][5].'</td>';
        echo '<td>'.$data[$i][6].'</td>';
        echo '<td>'.$data[$i][7].'</td>';
        echo '</tr><br />';
    }

    echo "</form>";
    echo "</table>";
    echo "</div>";
    echo '<input type="submit"  value="delete"  name="submit" style="position:absolute;top:820px;left:600px;">';
    echo " </form> ";
  ?>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js" integrity="sha384-vZ2WRJMwsjRMW/8U7i6PWi6AlO1L79snBrmgiDpgIWJ82z8eA5lenwvxbMV1PAh7" crossorigin="anonymous"></script>

1 个答案:

答案 0 :(得分:0)

要提交没有JavaScript / jQuery的表单,我们必须使用表单打开/关闭标记和提交按钮。 您忘记使用表单打开标记并提交表单按钮:

表单打开标记: <form action="" method="post">

提交按钮以提交表单: <input type="submit" name="submit" value="search">

我已使用评论编辑您的代码,请尝试以下更新的脚本:

<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="x-ua-compatible" content="ie=edge">

    <title>Stack - QA</title>

    <style media="screen">
    #listdiv1{
      position: relative;
      display:block;
      left:15%;
    }
    body{ background-color: rgb(231, 187, 82); }
    th {
      font-variant: small-caps;
      font-weight: lighter;
      color:red;
    }
    </style>
  </head>

  <body>

    <div id="listdiv1" style="background-
          color:red;width:1400px;height:900px;position:relative;top:20px;">

      <div id="listDivIn2" style="background-color:blue;width:1400px;height:900px;display:inline-block;position: absolute;">

      <!-- form open tag with action= path-to-action-page and method = get/post attribute  -->
      <form action="" method="post">
          <h1 style="margin-left:500px;font-family:Trebuchet MS;font-variant: small-caps;"> Customers List</h1>
        <div style="position:absolute;top:80px;margin-left:60px;">
        <label style="font-family:Trebuchet MS;color:rgb(187, 218, 177);">Customer_Name</label><input type="text" name="cn_tosearch" placeholder="enter name" style="position: absolute;width:300px;margin-left:14px" /></br>
        <label style="margin-left:30px;font-family:Trebuchet MS;color:rgb(187, 218, 177);">Date</label><input type="text" name="Date_tosearch" placeholder="enter date"  style="position: absolute;margin-left:68px;width:300px;"  /></div></br>
         <input type="submit" class="btn btn-secondary" name="submit" value="Search" style="position:absolute;top:150px;left:280px;">
      </form>

      <div id="divtable" style="background-color:black;width:1200px;height:570px;position:absolute;top:220px;margin-left:90px;" >

        <table style="width:100%;position:absolute;color:red;margin-left:35px;top:10px;" >
        <?php
          $dbs=mysqli_connect("localhost","root","","biz_dairy")
          or die("connection error");
          $q="select * from add_customer";
          $result=mysqli_query($dbs,$q)
          or die("error in query");
          $data=mysqli_fetch_all($result);
           mysqli_close($dbs);
          $c=count($data);

         echo "<tr><th>date</th><th>name</th><th>fanme</th><th>gender</th><th>mob_no</th><th>email</th><th>address</th><th>balance</th></tr>";
         echo  '<form name="register"  method="POST" action="$_SERVER[\'PHP_SELF\']" >';


         for ($i = 0; $i <= $c-1; $i++)
         {

            echo '<input type="checkbox" name="delete[]" value="delete" style="position:relative;top:34px;left:6px;" /><tr>';
            echo '<td>'.$data[$i][0].'</td>';
            echo '<td>'.$data[$i][1].'</td>';
            echo '<td>'.$data[$i][2].'</td>';
            echo '<td>'.$data[$i][3].'</td>';
            echo '<td>'.$data[$i][4].'</td>';
            echo '<td>'.$data[$i][5].'</td>';
            echo '<td>'.$data[$i][6].'</td>';
            echo '<td>'.$data[$i][7].'</td>';

           echo '</tr><br />';
        }
      ?>

    </table> <!-- close tabel -->

  </div>

<!-- scripts -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js" integrity="sha384-vZ2WRJMwsjRMW/8U7i6PWi6AlO1L79snBrmgiDpgIWJ82z8eA5lenwvxbMV1PAh7" crossorigin="anonymous"></script>
相关问题