繁体   English   中英

从 html 表中选择数据并发送到数据库

[英]Selecting data from html table and send it to database

我是使用 php 和 html 的新手。我不知道如何解决这个问题。我正在尝试 select 从数据库中获取数据并将其显示在 html 表中,并且在每一行之后都有指定的按钮。 如果我单击该按钮,则应保存该行中的数据,以便我可以使用它来将其插入到其他表中。 [在 select 列中,我想在单击按钮后添加一个按钮,应保存该行中的数据,以便以后使用1

这是用于获取数据并将其显示在表格中的代码。

 <table style="background-color: white" id="myTable"> <tr> <th> <h1> Email </h1> </th> <th> <h1> Password </h1> </th> <th> <h1> Select </h1> </th> </tr> <?php include 'db_connnection.php'; $conn = OpenCon(); $sql1= "SELECT Email,Password from doctor_information "; $result=mysqli_query($conn,$sql1); $count=mysqli_num_rows($result); if($count < 0) { echo "No Records Available"; } else{ $array1=array(); $count1=0; while ( $row = mysqli_fetch_array($result)) { echo "<tr><td>".$row['Email']."<td>".$row['Password']."<td>"; ?> <?php } }?> </table>

如果有任何其他方法可以解决指导我,则没有必要使用表格。 任何帮助将不胜感激。

有一个像这样的锚标签:-

    <?php

 include 'db_connnection.php';
   $conn = OpenCon();

$sql1= "SELECT * from doctor_information";
$result=mysqli_query($conn,$sql1);
$count=mysqli_num_rows($result);
   if($count < 0) {
            echo "No Records Available";
        }
        else{
         $array1=array();
         $count1=0;
    while($row=mysqli_fetch_array($result))  {  ?>      
    <tr>
         <td> <?php echo $row['Email'];?>  </td>
         <td> <?php echo $row['Password'];?>   </td>
         <td><a href=insert.php?id="<?php echo $row['Email'];?>">INSERT DATA</a></td>    </tr>
<?php } }  ?>

然后也许在你的 insert.php

<?php
    if(isset($_GET['id']) {
        $Email = $_GET['id'];
        /* your code here to get Email from database, 
        and then insert code with that email
    }
?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM