Search box
This is a very useful project, you can put search box above and pagination
<div class="container"> <h1 align="center">PHP/MySQL Add, Edit, Delete, With User Profile.</h1> <div class="page-header"> <h1 class="h2"> List of Members<a class="btn btn-success" href="addmember.php" style="margin-left: 770px;"><span class="glyphicon glyphicon-user"></span> Add Member</a></h1><hr> </div> <div class="row"> <?php $stmt = $DB_con->prepare('SELECT userid, username, description, userprofile FROM users ORDER BY userid DESC'); $stmt->execute(); if($stmt->rowCount() > 0) { while($row=$stmt->fetch(PDO::FETCH_ASSOC)) { ?> <div class="col-xs-3"> <h3 class="page-header" style="background-color:cadetblue" align="center"><?php echo $username."<br>".$description; ?></h3> <img src="uploads/<?php echo $row['userprofile']; ?>" class="img-rounded" width="250px" height="250px" /><hr> <p class="page-header" align="center"> <span> <a class="btn btn-primary" href="editform.php?edit_id=<?php echo $row['userid']; ?>"><span class="glyphicon glyphicon-pencil"></span> Edit</a> <a class="btn btn-warning" href="?delete_id=<?php echo $row['userid']; ?>" title="click for delete" onclick="return confirm('Are You Sure You Want To Delete This User?')"><span class="glyphicon glyphicon-trash"></span> Delete</a> </span> </p> </div> <?php } } else { ?> <div class="col-xs-12"> <div class="alert alert-warning"> <span class="glyphicon glyphicon-info-sign"></span> No Data Found. </div> </div> <?php } ?> </div> </div>
<?php require_once 'dbcon.php'; { $stmt_select = $DB_con->prepare('SELECT userprofile FROM users WHERE userid =:uid'); $imgRow=$stmt_select->fetch(PDO::FETCH_ASSOC); $stmt_delete = $DB_con->prepare('DELETE FROM users WHERE userid =:uid'); $stmt_delete->bindParam(':uid',$_GET['delete_id']); $stmt_delete->execute(); } ?>
<?php require_once 'dbcon.php'; { $id = $_GET['edit_id']; $stmt_edit = $DB_con->prepare('SELECT username, description, userprofile FROM users WHERE userid =:uid'); $edit_row = $stmt_edit->fetch(PDO::FETCH_ASSOC); } else { } { $username = $_POST['user_name']; $description = $_POST['description']; $imgFile = $_FILES['user_image']['name']; $tmp_dir = $_FILES['user_image']['tmp_name']; $imgSize = $_FILES['user_image']['size']; if($imgFile) { $upload_dir = 'uploads/'; { if($imgSize < 5000000) { } else { $errMSG = "Sorry, Your File Is Too Large To Upload. It Should Be Less Than 5MB."; } } else { $errMSG = "Sorry, only JPG, JPEG, PNG & GIF Extension Files Are Allowed."; } } else { $userprofile = $edit_row['userprofile']; } { $stmt = $DB_con->prepare('UPDATE users SET username=:uname, description=:udes, userprofile=:upic WHERE userid=:uid'); $stmt->bindParam(':uname',$username); $stmt->bindParam(':udes',$description); $stmt->bindParam(':upic',$userprofile); $stmt->bindParam(':uid',$id); if($stmt->execute()){ ?> <script> alert('Successfully Updated...'); window.location.href='home.php'; </script> <?php } else{ $errMSG = "Sorry User Could Not Be Updated!"; } } } ?>
<?php require_once 'dbcon.php'; { $id = $_GET['edit_id']; $stmt_edit = $DB_con->prepare('SELECT username, description, userprofile FROM users WHERE userid =:uid'); $edit_row = $stmt_edit->fetch(PDO::FETCH_ASSOC); } else { } { $username = $_POST['user_name']; $description = $_POST['description']; $imgFile = $_FILES['user_image']['name']; $tmp_dir = $_FILES['user_image']['tmp_name']; $imgSize = $_FILES['user_image']['size']; if($imgFile) { $upload_dir = 'uploads/'; { if($imgSize < 5000000) { } else { $errMSG = "Sorry, Your File Is Too Large To Upload. It Should Be Less Than 5MB."; } } else { $errMSG = "Sorry, only JPG, JPEG, PNG & GIF Extension Files Are Allowed."; } } else { $userprofile = $edit_row['userprofile']; } { $stmt = $DB_con->prepare('UPDATE users SET username=:uname, description=:udes, userprofile=:upic WHERE userid=:uid'); $stmt->bindParam(':uname',$username); $stmt->bindParam(':udes',$description); $stmt->bindParam(':upic',$userprofile); $stmt->bindParam(':uid',$id); if($stmt->execute()){ ?> <script> alert('Successfully Updated...'); window.location.href='home.php'; </script> <?php } else{ $errMSG = "Sorry User Could Not Be Updated!"; } } } ?>