Unable to get MySQL to print on page with if statement

  Kiến thức lập trình

I seem to be running into some troubles getting in if statement if ($row ['approved'] == "1" && $row ['org'] == "dfa" ) working in the below script. The db has “1” in approved and “dfa” in org however it doesn’t output the db. If I remove it then it works fine however won’t print anything with it in. I had the statement working before I put page numbering in so unsure if that’s whats stopping it. Any help would be appreciated. TIA

    //define total number of results you want per page  
    $results_per_page = 2;  
  
    //find the total number of results stored in the database  
    $query = "select *from test";  
    $result = mysqli_query($conn, $query);  
    $number_of_result = mysqli_num_rows($result);  
  
    //determine the total number of pages available  
    $number_of_page = ceil ($number_of_result / $results_per_page);  
  
    //determine which page number visitor is currently on  
    if (!isset ($_GET['page']) ) {  
        $page = 1;  
    } else {  
        $page = $_GET['page'];  
    }  
  
    //determine the sql LIMIT starting number for the results on the displaying page  
    $page_first_result = ($page-1) * $results_per_page;  
  
    //retrieve the selected results from database   
    $query = "SELECT *FROM test LIMIT " . $page_first_result . ',' . $results_per_page;  
    $result = mysqli_query($conn, $query);  
    
    
         if ($row ['approved'] == "1" && $row  ['org'] == "dfa" )
{
    //display the retrieved result on the webpage  
    while ($row = mysqli_fetch_array($result)) {  
        echo $row['id'] . ' ' . $row['review'] . '</br>';  
    }  

    
  
    //display the link of the pages in URL  
    for($page = 1; $page<= $number_of_page; $page++) {  
        echo '<a href = "index2.php?page=' . $page . '">' . $page . ' </a>';  
    }  
}
  

?> 


Removed if statement

New contributor

Michael Long is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT