简体   繁体   English

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

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

I am new in using php and html. I have no idea to solve this issue.I am trying to select fetching data from database and display it in html tables and after every row there is button to appoint.我是使用 php 和 html 的新手。我不知道如何解决这个问题。我正在尝试 select 从数据库中获取数据并将其显示在 html 表中,并且在每一行之后都有指定的按钮。 if i click that button the data in the row should be saved so i can use it to insert it on other table.如果我单击该按钮,则应保存该行中的数据,以便我可以使用它来将其插入到其他表中。 [In the select column i want to add a buttton after clicking the button the data in the row should be saved so i can use it later 1 [在 select 列中,我想在单击按钮后添加一个按钮,应保存该行中的数据,以便以后使用1

This is code for fetching data and displaying it in table.这是用于获取数据并将其显示在表格中的代码。

 <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>

It is not necessary to use a table if there is any other way to solve guide me.如果有任何其他方法可以解决指导我,则没有必要使用表格。 Any help will be appreciated.任何帮助将不胜感激。

have an anchor tag like this:-有一个像这样的锚标签:-

    <?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 } }  ?>

then maybe in your insert.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