Click here to Skip to main content
15,884,472 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
QuestionAapanel upload project laravel Pin
marziyeh barooei9-May-22 1:05
marziyeh barooei9-May-22 1:05 
Questionhow do I get total quantity from this code Pin
wixily jnr28-Apr-22 13:29
wixily jnr28-Apr-22 13:29 
AnswerRe: how do I get total quantity from this code Pin
Richard MacCutchan28-Apr-22 21:31
mveRichard MacCutchan28-Apr-22 21:31 
QuestionROLES ET PRIVILEGES UTILISATEURS D'UN SITE Pin
ameb290825-Apr-22 4:06
ameb290825-Apr-22 4:06 
QuestionHow can I do a google search and get results in backend using JS or PHP? Pin
Social Bookmarking Site14-Apr-22 15:27
Social Bookmarking Site14-Apr-22 15:27 
Questionproblem in pagination click Pin
irfankundi7861-Apr-22 23:39
irfankundi7861-Apr-22 23:39 
AnswerRe: problem in pagination click Pin
Richard Deeming3-Apr-22 21:36
mveRichard Deeming3-Apr-22 21:36 
GeneralRe: problem in pagination click Pin
irfankundi7864-Apr-22 4:01
irfankundi7864-Apr-22 4:01 
i proved code of page Problem is when any condition is true and pagination is created according to condition then upon clicking any page why page number is wrong in below part


<?php
include('includes/checklogin.php');
check_login();
?>
<!DOCTYPE html>
<html lang="en">
<?php @include("includes/head.php");?>
<body>
  <div class="container-scroller">
    <!-- partial:../../partials/_navbar.html -->
    <?php @include("includes/header.php");?>
    <!-- partial -->
    <div class="container-fluid page-body-wrapper">
      <!-- partial:../../partials/_sidebar.html -->
      <?php @include("includes/sidebar.php");?>
      <!-- partial -->
      <div class="main-panel">
        <div class="content-wrapper">
          <div class="row">
            <div class="col-lg-12 grid-margin stretch-card">
              <div class="card">
               
                <!--  start  modal -->
                <div id="editData5"   class="modal fade">
                  <div class="modal-dialog modal-lg">
                    <div class="modal-content" >
                      <div class="modal-header" >
                        
                        <h5 class="modal-title" >View Visitor details</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                          <span aria-hidden="true"</span>
                        </button>
                      </div>
                      <div class="modal-body" id="info_update5">
                        <?php @include("view_visitor_details.php");?>
                      </div>
                      <div class="modal-footer ">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                      </div>
                      <!-- /.modal-content -->
                    </div>
                    <!-- /.modal-dialog -->
                  </div>
                  <!-- /.modal -->
                </div>
                
                <h4  class="new-title">View Visitor details</h4>
                <!--   end modal -->
                <div class="table-responsive p-3" style="margin-top: -15px;">
                  <table class="content-table" id="dataTableHover">
                    <thead>
                      <tr>
                        <th class="text-center">No</th>
                        <th class="text-center">Full Name</th>
                        <th class="text-center">Card#</th>
                        <th class="text-center">Department</th>
                        <th class="text-center">Facility Visit</th>
                        <th class="text-center">Status</th>
                        <th class="text-center">Reg Date</th>
                        <th class="text-center" style="width: 15%;">Action</th>
                      </tr>
                    </thead>
                    <tbody>
                      <?php
                        if(isset($_POST['search']) & !empty($_POST['searchdata']) )
                        { 
                          session_start();
                          $pdf_data =$_POST['searchdata'];
                           $_SESSION['pdf-data']= $pdf_data;
                           
                          $sdata=$_POST['searchdata'];
                //pagination code
                            $limit=10;
                           if(isset($_GET['page1']))
                           {
                            $page=$_GET['page1'];
                            $cnt=(($page-1)*$limit)  + 1;
                           }
                           else
                           {

                            $page=1;
                           $cnt=1;
                           }
                           $offset = ($page-1)*$limit;

                          ?>
                          <h4 align="center">Result against "<?php echo $sdata;?>" keyword </h4>
                               <?php   
                               $query="select * from tblvisitor where  FullName like '%$sdata%'||MobileNumber like '$sdata%'"; 
                                $sql_run=mysqli_query($connection,$query);
                                $num_rows = mysqli_affected_rows( $connection );
                                $cnt=1;
                                while ($row=mysqli_fetch_array($sql_run))
                                 {
                                   ?>
                                    <tr>
                            
                                    <td class="text-center"><?php echo ($cnt);?></td>
                                    <td class="text-center"><?php  echo $row['FullName'];?></td>
                                    <td class="text-center"><?php  echo $row['Cardno'] ;?></td>
                                     <td class="text-center"><?php  echo $row['Deptartment'] ;?></td>
                                    <td class="text-center"><?php  echo $row['Facility'] ;?></td>
                                    <td class="text-center"><?php  echo $row['Status'];?></td>
                                    <td class="text-center"><?php  echo date ("d-m-Y", strtotime($row['EnterDate'])  );?></td>
                                    <td class=" text-center">
                                      <a href="#"  class=" edit_data5" id="<?php echo $row['ID'] ?>" title="click to view"class="mdi mdi-eye"></a>
                                    </td>
                                  </tr>
                                  <?php 
                                    $cnt=$cnt+1;
                        
                                    }}

 elseif (isset($_POST['search']) & !empty($_POST['date-search'])) {
   echo "elseif for pagnation of data wise search is started" ;    
   session_start();
     $sdata=$_POST['date-search'];
      $_SESSION['pdf-newdata']= $sdata;

                                
                                ?>
                                <h4 align="center">Result against "<?php echo date ('d-m-Y', strtotime($sdata));?>" keyword </h4>
                                <?php
          //pagination code
                            $limit=10;
                           if(isset($_GET['page']))
                           {
                            $page=$_GET['page'];
                            $cnt=(($page-1)*$limit)  + 1;
                           }
                           else
                           {

                            $page=1;
                           $cnt=1;
                           }
                           $offset = ($page-1)*$limit;

                                $new_date=date ('d-m-Y', strtotime($sdata));
                                echo $new_date;
                                $query="select * from tblvisitor where date_format(enterdate,'%Y-%m-%d')=date('$sdata') LIMIT {$offset},{$limit}"; 
                                $sql_run=mysqli_query($connection,$query);
                                $num_rows = mysqli_affected_rows( $connection );
                                $cnt=1;
                                while ($row=mysqli_fetch_array($sql_run))
                                 {
                                   ?>
                                   <tr>
                            
                                    <td class="text-center"><?php echo ($cnt);?></td>
                                    <td class="text-center"><?php  echo $row['FullName'];?></td>
                                    <td class="text-center"><?php  echo $row['Cardno'] ;?></td>
                                     <td class="text-center"><?php  echo $row['Deptartment'] ;?></td>
                                    <td class="text-center"><?php  echo $row['Facility'] ;?></td>
                                    <td class="text-center"><?php  echo $row['Status'];?></td>
                                    <td class="text-center"><?php  echo date ("d-m-Y", strtotime($row['EnterDate'])  );?></td>
                                    <td class=" text-center">
                                      <a href="#"  class=" edit_data5" id="<?php echo $row['ID'] ?>" title="click to view"class="mdi mdi-eye"></a>
                                    </td>
                                  </tr>
                                  <?php 
                                    $cnt=$cnt+1;
                                        }}

                   else  {     ?>
                   <?php    
                      echo "after pagantion else if is started";
                     

                     session_start();
                     
                          $pdf_data =$_POST['searchdata'];
                          $_SESSION['pdf-data']= $pdf_data;
                          $sdata=$_POST['date-search'];
                          $_SESSION['pdf-newdata']= $sdata;  

                         $limit=10;
                           
                           if(isset($_GET['page']))
                           {
                            $page=$_GET['page'];
                            
                            $cnt=(($page-1)*$limit)  + 1;
                           
                           }
                           else
                           {

                            $page=1;
                           $cnt=1;
                           }
                           $offset = ($page-1)*$limit;
                  
                      $connection = mysqli_connect("localhost","root","","cvdb");
                      $query="SELECT * from tblvisitor ORDER BY id DESC LIMIT {$offset},{$limit}" ;
                      $sql_run=mysqli_query($connection,$query);
                      $num_rows = mysqli_affected_rows( $connection );
                     
                     

                      while ($row=mysqli_fetch_array($sql_run)) {
          
                          ?>
                          <tr>
                            
                            <td class="text-center"><?php echo ($cnt);?></td>
                            <td class="text-center"><?php  echo $row['FullName'];?></td>
                            <td class="text-center"><?php  echo $row['Cardno'] ;?></td>
                             <td class="text-center"><?php  echo $row['Deptartment'] ;?></td>
                            <td class="text-center"><?php  echo $row['Facility'] ;?></td>
                            <td class="text-center"><?php  echo $row['Status'];?></td>
                            <td class="text-center"><?php  echo date ("d-m-Y", strtotime($row['EnterDate'])  );?></td>
                            <td class=" text-center">
                              <a href="#"  class=" edit_data5" id="<?php echo $row['ID'] ?>" title="click to view"class="mdi mdi-eye"></a>
                            </td>
                          </tr>
                          <?php 

                         $cnt=$cnt+1;
                         $tot_rec=$cnt;
                       
                      }

                    } ?>
                    </tbody>
                  </table>
                
<?php
// Main Pagination Section
// pagination for name and mobile criteria is selected
 if(isset($_POST['search']) & !empty($_POST['searchdata']) )
 {
 

echo "pagntion mobile and name";
$connection2 = mysqli_connect("localhost","root","","cvdb");
                      $query2="select * from tblvisitor where  FullName like '%$sdata%'||MobileNumber like '$sdata%' " ;
                      $sql_run2=mysqli_query($connection2,$query2);
                      $num_rows2 = mysqli_affected_rows( $connection2 );
                     echo $num_rows2;
                      echo '<ul class="pagination pagination-sm">';
                      if ($page>1)
                      {
                        echo '<li><a href="manage_visitor.php?page='.($page - 1).'" class="page-link" >Prev</a></li>';
                      }
                      
                     if (mysqli_num_rows($sql_run2)>0 )
                     {
                       $total_record = mysqli_num_rows($sql_run2);
                       //echo $total_record;
                      //$limit=10;
                       $total_pages = ceil($total_record/$limit);
                       
                        for ($i=1; $i<=$total_pages;$i++)
                        {
                         if ($i == $page)
                         {
                          $active="page-item active";
                         }
                       else
                       {
                        $active="";
                       }
                         echo '<li class="'.$active.'" ><a class="page-link" href="manage_visitor.php?page1='.$i.'">'.$i.'</a></li>';
                       } 
                        if ( $total_pages>$page)
                      {
                        echo '<li><a href="manage_visitor.php?page='.($page + 1).'" class="page-link" >Next</a></li>';
                      }
                       
                        echo '</ul>';
                        
                      }
 }
 //pagination for date wise criteria
 elseif (isset($_POST['search']) & !empty($_POST['date-search']))
  {
   echo "pagnation  date wise search " ; 
   $connection2 = mysqli_connect("localhost","root","","cvdb");
                      $query2="select * from tblvisitor where date_format(enterdate,'%Y-%m-%d')=date('$sdata')  " ;
                      $sql_run2=mysqli_query($connection2,$query2);
                      $num_rows2 = mysqli_affected_rows( $connection2 );
                     echo $num_rows2;
                      echo '<ul class="pagination pagination-sm">';
                      if ($page>1)
                      {
                        echo '<li><a href="manage_visitor.php?page='.($page - 1).'" class="page-link" >Prev</a></li>';
                      }
                      
                     if (mysqli_num_rows($sql_run2)>0 )
                     {
                       $total_record = mysqli_num_rows($sql_run2);
                       //echo $total_record;
                      //$limit=10;
                       $total_pages = ceil($total_record/$limit);
                       
                        for ($i=1; $i<=$total_pages;$i++)
                        {
                         if ($i == $page)
                         {
                          $active="page-item active";
                         }
                       else
                       {
                        $active="";
                       }
                         echo '<li class="'.$active.'" ><a class="page-link" href="manage_visitor.php?page='.$i.'">'.$i.'</a></li>';
                       } 
                        if ( $total_pages>$page)
                      {
                        echo '<li><a href="manage_visitor.php?page='.($page + 1).'" class="page-link" >Next</a></li>';
                      }
                       
                        echo '</ul>';
                        
                      }
 }
 //pagination for when no Cretia is selected
 else
 {
echo "else pagntion no search criterai ";
                      $connection1 = mysqli_connect("localhost","root","","cvdb");
                      $query1="SELECT * from tblvisitor ORDER BY id DESC " ;
                      $sql_run1=mysqli_query($connection,$query1);
                      $num_rows1 = mysqli_affected_rows( $connection );

                      echo '<ul class="pagination pagination-sm">';
                      if ($page>1)
                      {
                        echo '<li><a href="manage_visitor.php?page='.($page - 1).'" class="page-link" >Prev</a></li>';
                      }
                      
                     if (mysqli_num_rows($sql_run1)>0 )
                     {
                       $total_record = mysqli_num_rows($sql_run1);
                       //echo $total_record;
                      //$limit=10;
                       $total_pages = ceil($total_record/$limit);
                       
                        for ($i=1; $i<=$total_pages;$i++)
                        {
                         if ($i == $page)
                         {
                          $active="page-item active";
                         }
                       else
                       {
                        $active="";
                       }
                         echo '<li class="'.$active.'" ><a class="page-link" href="manage_visitor.php?page='.$i.'">'.$i.'</a></li>';
                       } 
                        if ( $total_pages>$page)
                      {
                        echo '<li><a href="manage_visitor.php?page='.($page + 1).'" class="page-link" >Next</a></li>';
                      }
                       
                        echo '</ul>';
                        }
                      }
?>
                </div>

  
   <!-- <li class="page-item active" aria-current="page">-->
       
              </div>
            </div>
          </div>
        </div>
        <!-- content-wrapper ends -->
        <!-- partial:../../partials/_footer.html -->
        <?php @include("includes/footer.php");?>
        <!-- partial -->
      </div>
      <!-- main-panel ends -->
    </div>
    <!-- page-body-wrapper ends -->
  </div>
  <!-- container-scroller -->
  <?php @include("includes/foot.php");?>
  <!-- End custom js for this page -->
  <script type="text/javascript">
    $(document).ready(function(){
      $(document).on('click','.edit_data5',function(){
        var edit_id5=$(this).attr('id');
        $.ajax({
          url:"view_visitor_details.php",
          type:"post",
          data:{edit_id5:edit_id5},
          success:function(data){
            $("#info_update5").html(data);
            $("#editData5").modal('show');
          }
        });
      });
    });
  </script>

</body>
</html>

QuestionGUI for Linux Server Pin
Deepak Vasudevan25-Jan-22 3:29
Deepak Vasudevan25-Jan-22 3:29 
QuestionError in page rendering in php Pin
Rahul Gupta Jan202217-Jan-22 1:16
Rahul Gupta Jan202217-Jan-22 1:16 
AnswerRe: Error in page rendering in php Pin
Richard Deeming17-Jan-22 1:53
mveRichard Deeming17-Jan-22 1:53 
Questionhow to add date while importing data in csv from mysql query Pin
him_mca16-Jan-22 20:00
him_mca16-Jan-22 20:00 
Questioni want make check user offline with mysql Pin
Ping tester1-Jul-21 10:56
Ping tester1-Jul-21 10:56 
QuestionHow to print for each primary key all the foreign keys column related to it? Pin
EliotSimpleMan5-May-21 14:40
EliotSimpleMan5-May-21 14:40 
AnswerRe: How to print for each primary key all the foreign keys column related to it? Pin
SeanChupas13-May-21 1:50
SeanChupas13-May-21 1:50 
QuestionHow do I calculate the column in PHP union all function Pin
Developer Account18-Apr-21 23:12
Developer Account18-Apr-21 23:12 
AnswerRe: How do I calculate the column in PHP union all function Pin
SeanChupas13-May-21 1:51
SeanChupas13-May-21 1:51 
QuestionPHP :: VSCode always opens a new blank window (untitled-1) Pin
Gustavo Laufer AU4-Apr-21 22:00
Gustavo Laufer AU4-Apr-21 22:00 
AnswerRe: PHP :: VSCode always opens a new blank window (untitled-1) Pin
SeanChupas5-Apr-21 3:15
SeanChupas5-Apr-21 3:15 
Questioni have this errors in my project please i need help Pin
frank saki24-Mar-21 11:55
frank saki24-Mar-21 11:55 
AnswerRe: i have this errors in my project please i need help Pin
Richard Deeming24-Mar-21 22:12
mveRichard Deeming24-Mar-21 22:12 
QuestionHow can I echo the numbers using list() function in foreach loop? Pin
Best Tutor24-Feb-21 9:33
Best Tutor24-Feb-21 9:33 
QuestionRe: How can I echo the numbers using list() function in foreach loop? Pin
Richard MacCutchan24-Feb-21 21:56
mveRichard MacCutchan24-Feb-21 21:56 
QuestionHow to import csv using php code Pin
Mohammed Hudair16-Feb-21 6:24
Mohammed Hudair16-Feb-21 6:24 
QuestionHow to code login page in html css php Pin
Member 150661826-Feb-21 1:01
Member 150661826-Feb-21 1:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.