我正在处理联系人申请,我必须使用以下代码中显示的联系按钮查看联系人

My code is below:

while($row = mysqli_fetch_array($result))  {
  echo "<tr><td>"."<input type='checkbox' name='checkbox[]' value=".$row['id'].">"."</td>"; echo "<td>" . $row['firstname']. "</td>";
  echo "<td>" . $row['lastname']. "</td>";
  echo "<td>" . $row['email']. "</td>";
  echo "<td>". "</td>";  echo "<td>"."<input type='button' name='view' id='view' value='View'  />"."</td>";     echo "</tr>";
echo "</tbody>"; }
echo "</table>";  }   ?>

According to your question , i guess you like to fetch the detail of a certain record.I've put some of code here . The easiest way to use button instead of a , use bootstrap.

db.php

<?php
class Database
{
    private static $dbName = 'Customer' ;
    private static $dbHost = 'localhost' ;
    private static $dbUsername = 'root';
    private static $dbUserPassword = '';

    private static $cont  = null;

    public function __construct() {
        die('Init function is not allowed');
    }

    public static function connect()
    {
       // One connection through whole application
       if ( null == self::$cont )
       {     
        try
        {
          self::$cont =  new PDO( "mysql:host=".self::$dbHost.";"."dbname=".self::$dbName, self::$dbUsername, self::$dbUserPassword); 
        }
        catch(PDOException $e)
        {
          die($e->getMessage()); 
        }
       }
       return self::$cont;
    }

    public static function disconnect()
    {
        self::$cont = null;
    }
}
?>

dummy.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <link   href="css/bootstrap.min.css" rel="stylesheet">
    <script src="js/bootstrap.min.js"></script>
</head>

<body>
    <div class="container">
            <div class="row">
                <h3>PHP CRUD Grid</h3>
            </div>
            <div class="row">
                <table class="table table-striped table-bordered">
                  <thead>
                    <tr>
                      <th>Name</th>
                      <th>Email Address</th>
                      <th>Mobile Number</th>
                    </tr>
                  </thead>
                  <tbody>
                  <?php
                   include 'db.php';
                   $pdo = Database::connect();
                   $sql = 'SELECT * FROM contacts ORDER BY id DESC';
                   foreach ($pdo->query($sql) as $row) {
                            echo '<tr>';
                            echo '<td><a href="detail.php?id='.$row["id"].'">'. $row['name'] . '</a></td>';
                            echo '<td>'. $row['email'] . '</td>';
                            echo '<td>'. $row['mobile'] . '</td>';
                            echo '</tr>';
                   }
                   Database::disconnect();
                  ?>
                  </tbody>
            </table>
        </div>
    </div> <!-- /container -->
  </body>
</html>

detail.php

<?php 
  $id = $_GET['id'];
?>

<?php
 include 'db.php';
 $pdo = Database::connect();
 $sql = 'SELECT * FROM contacts WHERE id='.$id;
 foreach ($pdo->query($sql) as $row) {
          echo "<div>";
          echo "<p> ".$row['name']." </p>";
          echo "<p> ".$row['email']." </p>";
          echo "<p> ".$row['mobile']." </p>";
          echo "</div>";

 }
 Database::disconnect();
?>

Let's assume i've database name "Customer" and table name "contacts" . db.php is database connection class. if you look at the dummy.php , you will find that you already achieved the list of records. So to answer your question , i put a tag in name field and which redirect to detail.php with parameter of id . there you can fetch the detail of contact .. Hope it might answer your needs