skip to Main Content

I want to get multiple table data into a page.
Actually, I am trying to get table data according to its page id.

                   $page = $_GET['v'];                               
                   if($page == 1){
                        $sel_data="SELECT * FROM fix ORDER BY fix_id DESC ";
                        $qri_res=mysqli_query($con,$sel_data);
                    }

                    if($page == 2){
                        $sel_data="SELECT * FROM seo ORDER BY   seo_id DESC ";
                        $qri_res=mysqli_query($con,$sel_data);
                    }                                                
                    if($page == 3){
                        $sel_data="SELECT * FROM err ORDER BY   err_id DESC ";
                        $qri_res=mysqli_query($con,$sel_data);
                    }          
                   while($total_row=mysqli_fetch_array($qri_res)){

but it resulting me only first one. Please help me to solve this out.

3

Answers


  1. You are overriding $qri_res. You must use 3 variables or appending the data result.

    Login or Signup to reply.
  2. I think it’s a problem with string versus int.

    Use this to make it a safe INT:

    $page = (int)$_GET['v']; 
    

    Use this to compare it

    if($page === 1){
    
    Login or Signup to reply.
  3.                $page = $_GET['v'];  
                   $sel_data ="";
    
     if($page == 1){ $sel_data="SELECT * FROM fix ORDER BY fix_id DESC ";}
    
     if($page == 2){ $sel_data="SELECT * FROM seo ORDER BY seo_id DESC "; }                                                
    
     if($page == 3){ $sel_data="SELECT * FROM err ORDER BY err_id DESC "; }   
    
     $qri_res = mysqli_query($con,$sel_data);
    
     while($total_row=mysqli_fetch_array($qri_res)){
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search