Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form method="post" action="search.php">
- <div class="input-group has-success">
- <input id="btn-input" name="search" type="text" class="form-control input-md" placeholder="Please type the ID number of the user you want to update..." />
- <span class="input-group-btn">
- <button class="btn btn-success btn-md" id="btn-chat" type="submit">Search</button>
- </span>
- </div>
- </form>
- </div>
- <div class="col-md-6">
- <form role="form">
- <div class="form-group">
- <label>username</label>
- <input class="form-control" placeholder="Placeholder">
- </div>
- <div class="form-group">
- <label>Password</label>
- <input class="form-control">
- </div>
- <div class="form-group">
- <label>UserType</label>
- <input class="form-control">
- </div>
- </form>
- <?php
- $conn = mysqli_connect("localhost", "root", "", "asset_inventory");
- if($conn === false){
- die("ERROR: Could not connect. " . mysqli_connect_error());
- }
- $search = mysqli_real_escape_string($conn, $_POST['search']);
- $sql = "SELECT * FROM users WHERE user_id='$search'";
- $result = mysqli_query($conn, $sql);
- if (mysqli_num_rows($result) > 0) {
- while($row = mysqli_fetch_assoc($result)) {
- $name=$row['user_name'];
- $pass=$row['user_pass'];
- $type=$row['user_type'];
- }
- } else {
- echo "0 results";
- }
- mysqli_close($conn);
- ?>
- if (mysqli_num_rows($result) > 0)
- {
- while($row = mysqli_fetch_assoc($result))
- {
- $name=$row['user_name'];
- $pass=$row['user_pass'];
- $type=$row['user_type'];
- }
- }
- else
- {
- echo "0 results";
- }
- <table>
- <?php
- if (mysqli_num_rows($result) > 0)
- {
- while($row = mysqli_fetch_assoc($result))
- {
- ?>
- <tr>
- <td> <?php echo $name=$row['user_name']; ?> </td>
- <td> <?php echo $name=$row['user_pass']; ?> </td>
- <td> <?php echo $name=$row['user_type']; ?> </td>
- </tr>
- <?php
- }
- }
- else
- {
- ?>
- <tr>
- <td colspan="3">0 results</td>
- </tr>
- <?php
- }
- ?>
- </table>
- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
- <script>
- $(function(){
- $(document).on("click", "#btn-chat", function(e) {
- e.preventDefault();
- //Built a url to send
- var info = $("#form").serialize();
- $.ajax({
- type: "POST",
- url: "search.php",
- data: info,
- success: function(result){
- //$('#respoondarea').load(location.href + '#respondarea');
- //$("#form")[0].reset();
- $('#respond').html(result);
- }
- });
- e.preventDefault();
- });
- });
- </script>
- <form method="post" id="form" action="search.php">
- <div class="input-group has-success">
- <input id="btn-input" name="search" type="text" class="form-control input-md" placeholder="Please type the ID number of the user you want to update..." />
- <span class="input-group-btn">
- <button class="btn btn-success btn-md" id="btn-chat" type="submit">Search</button>
- </span>
- </div>
- </form>
- <div id="respond"></div>
- <?php
- $conn = mysqli_connect("localhost", "root", "", "asset_inventory");
- if($conn === false){
- die("ERROR: Could not connect. " . mysqli_connect_error());
- }
- $search = $_POST['search'];
- //$query_user = mysqli_query($conn,"SELECT * FROM users WHERE user_id='$search'");
- $query_user = mysqli_query($conn,"SELECT * FROM users WHERE user_id LIKE '%$search%' ");
- $row_user = mysqli_fetch_assoc($query_user);
- $totalRows_user = mysqli_num_rows($query_user);
- ?>
- <table class="table">
- <thead>
- <tr>
- <th>Username</th><th>User pass</th><th>User type</th>
- </tr>
- </thead>
- <tbody>
- <?php do { ?>
- <tr>
- <td><?php echo $row_user['user_name']; ?></td>
- <td><?php echo $row_user['user_pass']; ?></td>
- <td><?php echo $row_user['user_type']; ?></td>
- </tr>
- <?php } while ($row_user = mysqli_fetch_assoc($query_user)); ?>
- </tbody>
- </table>
- <?php if ($totalRows_user == 0) { // Show if record empty ?>
- <div class="alert alert-info" role="alert"> No record found </div>
- <?php } // Show if recordset empty ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement