Posts

Showing posts from May, 2022

Pagination in PHP

Image
  Calculate total pages Different records on each page Calculate offset $limit = 5; if(isset($_REQUEST['page'])){ $page = $_REQUEST['page']; }else{ $page = 1; } $offset = ($page - 1) * $limit;     <!-- Pagination Start --> <div class="w3-row pagination">   <?php     $sql2 = "SELECT pro_id FROM project_request pr     INNER JOIN student s ON pr.pro_stu_id = s.stu_id     WHERE pr.pro_review = ?";       $result2 = $conn->prepare($sql2);     $result2->execute(array(0));     $row2 = $result2->fetchAll(PDO::FETCH_ASSOC);     if($result2->rowCount()){       $total_records = $result2->rowCount();       $total_pages = ceil($total_records/$limit);       echo '<ul>';       if($page > 1){         echo '<li class="w3-button w3-grey mx-1...

Image update in PHP with updating of other fields - Update Image with other fields

    <form action="" method="POST" enctype="multipart/form-data">   <label for="name">Name</label>   <input type="text" class="w3-input w3-border" id="name" name="name" required value="<?php echo $row2['stu_name']; ?>">   <label for="email">Email</label>   <input type="email" class="w3-input w3-border" id="email" name="email" required value="<?php echo $row2['stu_email']; ?>" >  <label for="profilepic">Profile Picture <small> (Note : Image size should be less than 500 KB) </small></label>  <input type="hidden" name="old-image" value="<?php if(isset($img)){ echo $img; }  ?>">   <input type="file" class="w3-input w3-border w3-white" id="profilepic"...