根据用户输入更改div的内容?

时间:2015-04-16 11:38:06

标签: php html mysql dynamic

我使用以下代码在我的数据库中创建了一个人员表:

<?php
    $servername = "localhost";
    $username = "username";
    $password = "password";
    $dbname = "database";

    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }

    $sql = "SELECT clientname, clientsurname, address1, postcode, dob FROM clients";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        echo "<table class='table table-bordered'><tr><th>Name</th>     <th>Surname</th><th>Address</th><th>Postcode</th><th>Date of Birth</th><th>Select Client</th></tr>";
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "<tr><td>".$row["clientname"]."</td><td>".$row["clientsurname"]."</td><td>".$row["address1"]."</td><td>".$row["postcode"]."</td><td>".$row["dob"]. "</td><td class='btn btn-block btn-info btn-flat'><a href=\"edit_form.php?id=$row[clientname]\" style='color:#fff;'>Select</a></td></tr>";
                            }
    echo "</table>";
    } else {
    echo "There are 0 clients in the system matching your search criteria";
   }
    $conn->close();
?>

我想知道当用户点击“选择客户端”按钮时,如果客户端完整数据可以将div填充到表格的一侧,是否可能?

如果可能,我该怎么做?

1 个答案:

答案 0 :(得分:2)

尝试在jquery中使用.fadeToggle或.fadeTo使其显示在屏幕的一侧。这可以通过许多不同的方式使用,但在大多数情况下,这就是它的样子。

$(document).ready(function(){
    $('button').click(function(){
        $('h2').fadeTo('fast',1);
    });
});

示例:http://jsfiddle.net/JoshuaHurlburt/x5f3bz37/