#16
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    845
    Rep Power
    0
    Originally Posted by Sepodati
    lol.... No, I do not. You have to be ****ing with us, right? Please??

    Now, you've created a bit of html in a loop. Good on you for that. How do you plan on processing the requst, when page 3 is requested, for example? How are you showing results 21-30, assuming 10 per page.

    You have no logic handling that.

    ****.
    I suspected this would be the case when I jumped into bed last night. Suddenly suspected that all pages would be showing the same rows.
    Anyway, I will try fixing this in another simplified way. Still, all that $query. (concatenation and stuff) is way over my head. Gonna try avoiding that as much as possible if I can't avoid the offset thing.
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    845
    Rep Power
    0
    Originally Posted by benanamen
    How many times do you have to be told to stop creating variables for nothing?
    I remember you told me once here and maybe once in codingforums.com but not sure about latter.
    I am going out now. When I return, I will seriously look into your complain. I did however, give you an explanation once upon a time to why I cerate the variables which you deem to be extra. I hope you still remember my explanation.
    Anyway, I'm going to jump into your pdo any day very soon.
    I'll bug you when I get stuck on pdo.
  4. #18
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    845
    Rep Power
    0
    I fixed my code. I replaced this:

    PHP Code:
    <tr name="user-details"> 
            <td bgcolor="#FFFFFF" name="submission-number"><?php echo $row['id']; ?></td> 
            <td bgcolor="#FFFFFF" name="logging-server-date-&-time"><?php echo $row['date_and_time']; ?></td> 
            <td bgcolor="#FFFFFF" name="recipient_username"><?php echo $row['recipient_username']; ?></td> 
            <td bgcolor="#FFFFFF" name="sender_username"><?php echo $row['sender_username']; ?></td> 
            <td bgcolor="#FFFFFF" name="notice"><?php echo $row['notice']; ?></td>  
            </tr>
    with this:
    PHP Code:
                <tr name="user-details">  
                <td bgcolor="#FFFFFF" name="submission-number"><?php printf("%s"$id); ?></td>  
                <td bgcolor="#FFFFFF" name="logging-server-date-and-time"><?php printf("%s"$date_and_time); ?></td>  
                <td bgcolor="#FFFFFF" name="username"><?php printf("%s"$recipient_username); ?></td>  
                <td bgcolor="#FFFFFF" name="gender"><?php printf("%s"$sender_username); ?></td>  
                <td bgcolor="#FFFFFF" name="age-range"><?php printf("%s"$notice); ?></td>  
        </tr>
    I have a question, is it true that with mysqli_fetch_array($result), I should only use echo $row['username'];
    And with mysqli_stmt_fetch, I should use printf("%s", $recipient_username);

    True or no ?

    Look at my first working code. it uses the former. It does not use PREP STMT. I grabbed the code from internet about 2yrs back. Note on line 95 the <?php while($row = mysqli_fetch_array($result)){ ?> and the echo $row['username'];

    Now, look at my 2nd code, I tried converting the first code to PREP STMT. Note on line 97 the <?php while($row = mysqli_stmt_fetch($stmt)){ ?> and the printf("%s", $recipient_username);

    PHP Code:
    <?php 

    //Required PHP Files. 
    include 'config.php'
    include 
    'header.php'

    //Check if User is already logged-in or not. Get the login_check() FUNCTION to check. 
    if (login_check() === FALSE

        
    //Redirect User to Log-in Page after 2 secs. 
        
    header("refresh:2; url=login.php"); 
        exit(); 

    else 

        
    //Grab User details from Session Variables and echo them. 
        
    $user $_SESSION["user"]; 
        
        
    $id $_SESSION["id"]; 
        
    $account_activation_status $_SESSION["account_activation_status"]; 
        
    $id_video_verification_status $_SESSION["id_video_verification_status"]; 
        
    $id_video_verification_url $_SESSION["id_video_verification_url"]; 
        
    $sponsor_username $_SESSION["sponsor_username"]; 
        
    $recruits_number $_SESSION["recruits_number"]; 
        
    $on_day_number_on_7_days_wish_list $_SESSION["on_day_number_on_7_days_wish_list"]; 
        
    $primary_website_domain $_SESSION["primary_website_domain"]; 
        
    $primary_website_email $_SESSION["primary_website_email"]; 
        
    $username $_SESSION["username"]; 
        
    $first_name $_SESSION["first_name"]; 
        
    $middle_name $_SESSION["middle_name"]; 
        
    $surname $_SESSION["surname"]; 
        
    $gender $_SESSION["gender"]; 
        
    $date_of_birth $_SESSION["date_of_birth"]; 
        
    $age_range $_SESSION["age_range"]; 
        
    $religion $_SESSION["religion"]; 
        
    $marital_status $_SESSION["marital_status"]; 
        
    $working_status $_SESSION["working_status"]; 
        
    $profession $_SESSION["profession"]; 
        
    $home_city $_SESSION["home_city"]; 
        
    $home_country $_SESSION["home_country"]; 
        
    ?> 
        <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional/EN"> 
        <html> 
        <head> 
        <meta content="text/html; charset=ISO-8859-1"  http-equiv="content-type"> 
        <title><?php echo $site_name?> User's Browsing Histories in <?php echo $server_time?> time.</title> 
        </head> 
        <body> 
        <br> 
        <center><span style="font-weight: bold;"><?php echo $site_name?> User's Browsing Histories in <?php echo $server_time?> time.</span></center> 
        <br> 
        <br> 
        <?php 
        
    //Connect to Mysql Server. 

        //Get Data from Table "browsing_histories". 
        
    $sql "SELECT * FROM browsing_histories"
        
    $result mysqli_query($conn,$sql); 
        
    //Total Number of Records 
        
    $rows_num mysqli_num_rows($result); 
        
    //Total Number of Pages Records to spread-over. 
        
    $page_count 10
        
    $page_size ceil($rows_num $page_count); 
        
    //Get the Page Number, Default is 1 (First Page). 
        
    $page_number $_GET["page_number"]; 
        if (
    $page_number == ""$page_number 1
            
    $offset = ($page_number -1) * $page_size
            
            
    $sql .= " limit {$offset},{$page_size}"
            
    $result mysqli_query($conn,$sql); 
        
    ?> 
        <table width="1500" border="0" cellpadding="5" cellspacing="2" bgcolor="#666666"> 
        <?php if($rows_num) {?> 
        <tr name="headings"> 
        <td bgcolor="#FFFFFF" name="column-heading_submission-number">Submission Number</td> 
        <td bgcolor="#FFFFFF" name="column-heading_browsed-page">Browsed Page</td> 
        <td bgcolor="#FFFFFF" name="column-heading_logging-server-date-&-time">Date & Time in <?php echo $server_time?></td> 
        <td bgcolor="#FFFFFF" name="column-heading_username">Username</td> 
        <td bgcolor="#FFFFFF" name="column-heading_username">Gender</td> 
        <td bgcolor="#FFFFFF" name="column-heading_username">Age Range</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_religion">Religion</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_education">Education</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_profession">Profession</td> 
            <td bgcolor="#FFFFFF" name="column-heading_working_status">Working Status</td> 
        <td bgcolor="#FFFFFF" name="column-heading_Marital_status">Marital Status</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_town">Home Town</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_borough">Home Borough</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_city">Home City</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_county">Home County</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_region">Home Region</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_state">Home State</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_country">Home Country</td> 
        <td bgcolor="#FFFFFF" name="column-heading_contact-page">Contact Page</td> 
        </tr> 
        <?php while($row mysqli_fetch_array($result)){ ?> 
        <tr name="user-details"> 
        <td bgcolor="#FFFFFF" name="submission-number"><?php echo $row['id']; ?></td> 
        <td bgcolor="#FFFFFF" name="browsed-page"><?php echo "<a href='"
                                                              echo 
    $row['browsed_page']; 
                                                              echo 
    "'>"
                                                              echo 
    "Browsed Page</a>"?></td> 
        <td bgcolor="#FFFFFF" name="logging-server-date-&-time"><?php echo $row['date_and_time']; ?></td> 
        <td bgcolor="#FFFFFF" name="username"><?php echo $row['username']; ?></td> 
        <td bgcolor="#FFFFFF" name="gender"><?php echo $row['gender']; ?></td> 
        <td bgcolor="#FFFFFF" name="age-range"><?php echo $row['age_range']; ?></td> 
        <td bgcolor="#FFFFFF" name="religion"><?php echo $row['religion']; ?></td> 
        <td bgcolor="#FFFFFF" name="education"><?php echo $row['education']; ?></td> 
        <td bgcolor="#FFFFFF" name="profession"><?php echo $row['profession']; ?></td> 
        <td bgcolor="#FFFFFF" name="working-status"><?php echo $row['working_status']; ?></td> 
        <td bgcolor="#FFFFFF" name="marital-status"><?php echo $row['marital_status']; ?></td> 
        <td bgcolor="#FFFFFF" name="home-town"><?php echo $row['home_town']; ?></td> 
        <td bgcolor="#FFFFFF" name="home-borough"><?php echo $row['home_borough']; ?></td> 
        <td bgcolor="#FFFFFF" name="home-city"><?php echo $row['home_city']; ?></td> 
        <td bgcolor="#FFFFFF" name="home-county"><?php echo $row['home_county']; ?></td> 
        <td bgcolor="#FFFFFF" name="home-region"><?php echo $row['home_region']; ?></td> 
        <td bgcolor="#FFFFFF" name="home-state"><?php echo $row['home_state']; ?></td> 
        <td bgcolor="#FFFFFF" name="home-country"><?php echo $row['home_country']; ?></td> 
        <td bgcolor="#FFFFFF" name="contact-page"><?php echo "<a href='"
                                                              echo 
    $row['contact_page']; 
                                                              echo 
    "'>"
                                                              echo 
    "Contact Page</a>"?></td> 
        </tr> 
        <?php ?> 
        <tr name="pagination"> 
        <td colspan="19" bgcolor="#FFFFFF"> Result Pages: 
        <?php 
            
    if($rows_num <= $page_size
            { 
                echo 
    "Page 1"
            } 
            else 
            { 
                for(
    $i=1;$i<=$page_count;$i++) 
                echo 
    "<a href=\"{$_SERVER['PHP_SELF']}?page_number={$i}\">{$i}</a>  "
            } 
            
    ?> 
        </td> 
        </tr> 
        <?php } else { ?> 
        <tr> 
        <td bgcolor="FFFFFF">No record found! Try another time.</td> 
        </tr> 
        <?php }?> 
        </table> 
        <br> 
        <br> 
        <center><span style="font-weight: bold;"><?php echo $site_name?> Users' Browsing Histories in <?php echo $server_time?> time.</span></center> 
        <br> 
        <br> 
    </div> 
    <br> 
    </body> 
    </html> 
    <?php 

    ?>
    I fixed my code to display the results from tbl. I replaced this:

    PHP Code:
    <tr name="user-details"> 
            <td bgcolor="#FFFFFF" name="submission-number"><?php echo $row['id']; ?></td> 
            <td bgcolor="#FFFFFF" name="logging-server-date-and-time"><?php echo $row['date_and_time']; ?></td> 
            <td bgcolor="#FFFFFF" name="recipient_username"><?php echo $row['recipient_username']; ?></td> 
            <td bgcolor="#FFFFFF" name="sender_username"><?php echo $row['sender_username']; ?></td> 
            <td bgcolor="#FFFFFF" name="notice"><?php echo $row['notice']; ?></td>  
            </tr>
    with this:
    PHP Code:
                <tr name="user-details">  
                <td bgcolor="#FFFFFF" name="submission-number"><?php printf("%s"$id); ?></td>  
                <td bgcolor="#FFFFFF" name="logging-server-date-&-time"><?php printf("%s"$date_and_time); ?></td>  
                <td bgcolor="#FFFFFF" name="username"><?php printf("%s"$recipient_username); ?></td>  
                <td bgcolor="#FFFFFF" name="gender"><?php printf("%s"$sender_username); ?></td>  
                <td bgcolor="#FFFFFF" name="age-range"><?php printf("%s"$notice); ?></td>  
        </tr>
    I have a question, is it true that with mysqli_fetch_array($result), I should only use echo $row['username'];
    And with mysqli_stmt_fetch, I should use printf("%s", $recipient_username);

    True or no ?

    Look at my first working code. it uses the former. It does not use PREP STMT. I grabbed the code from internet about 2yrs back. Note on line 95 the <?php while($row = mysqli_fetch_array($result)){ ?> and the echo $row['username'];

    Now, look at my 2nd code, I tried converting the first code to PREP STMT. Note on line 97 the <?php while($row = mysqli_stmt_fetch($stmt)){ ?> and the printf("%s", $recipient_username);

    PHP Code:
    <?php 

    //Required PHP Files. 
    include 'config.php'
    include 
    'header.php'

    //Check if User is already logged-in or not. Get the login_check() FUNCTION to check. 
    if (login_check() === FALSE

        
    //Redirect User to Log-in Page after 2 secs. 
        
    header("refresh:2; url=login.php"); 
        exit(); 

    else 

        
    //Grab User details from Session Variables and echo them. 
        
    $user $_SESSION["user"]; 
        
        
    $id $_SESSION["id"]; 
        
    $account_activation_status $_SESSION["account_activation_status"]; 
        
    $id_video_verification_status $_SESSION["id_video_verification_status"]; 
        
    $id_video_verification_url $_SESSION["id_video_verification_url"]; 
        
    $sponsor_username $_SESSION["sponsor_username"]; 
        
    $recruits_number $_SESSION["recruits_number"]; 
        
    $on_day_number_on_7_days_wish_list $_SESSION["on_day_number_on_7_days_wish_list"]; 
        
    $primary_website_domain $_SESSION["primary_website_domain"]; 
        
    $primary_website_email $_SESSION["primary_website_email"]; 
        
    $username $_SESSION["username"]; 
        
    $first_name $_SESSION["first_name"]; 
        
    $middle_name $_SESSION["middle_name"]; 
        
    $surname $_SESSION["surname"]; 
        
    $gender $_SESSION["gender"]; 
        
    $date_of_birth $_SESSION["date_of_birth"]; 
        
    $age_range $_SESSION["age_range"]; 
        
    $religion $_SESSION["religion"]; 
        
    $marital_status $_SESSION["marital_status"]; 
        
    $working_status $_SESSION["working_status"]; 
        
    $profession $_SESSION["profession"]; 
        
    $home_city $_SESSION["home_city"]; 
        
    $home_country $_SESSION["home_country"]; 
        
    ?> 
        <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional/EN"> 
        <html> 
        <head> 
        <meta content="text/html; charset=ISO-8859-1"  http-equiv="content-type"> 
        <title><?php echo $site_name?> User's Browsing Histories in <?php echo $server_time?> time.</title> 
        </head> 
        <body> 
        <br> 
        <center><span style="font-weight: bold;"><?php echo $site_name?> User's Browsing Histories in <?php echo $server_time?> time.</span></center> 
        <br> 
        <br> 
        <?php 
        
    //Connect to Mysql Server. 

        //Get Data from Table "browsing_histories". 
        
    $sql "SELECT * FROM browsing_histories"
        
    $result mysqli_query($conn,$sql); 
        
    //Total Number of Records 
        
    $rows_num mysqli_num_rows($result); 
        
    //Total Number of Pages Records to spread-over. 
        
    $page_count 10
        
    $page_size ceil($rows_num $page_count); 
        
    //Get the Page Number, Default is 1 (First Page). 
        
    $page_number $_GET["page_number"]; 
        if (
    $page_number == ""$page_number 1
            
    $offset = ($page_number -1) * $page_size
            
            
    $sql .= " limit {$offset},{$page_size}"
            
    $result mysqli_query($conn,$sql); 
        
    ?> 
        <table width="1500" border="0" cellpadding="5" cellspacing="2" bgcolor="#666666"> 
        <?php if($rows_num) {?> 
        <tr name="headings"> 
        <td bgcolor="#FFFFFF" name="column-heading_submission-number">Submission Number</td> 
        <td bgcolor="#FFFFFF" name="column-heading_browsed-page">Browsed Page</td> 
        <td bgcolor="#FFFFFF" name="column-heading_logging-server-date-and-time">Date & Time in <?php echo $server_time?></td> 
        <td bgcolor="#FFFFFF" name="column-heading_username">Username</td> 
        <td bgcolor="#FFFFFF" name="column-heading_username">Gender</td> 
        <td bgcolor="#FFFFFF" name="column-heading_username">Age Range</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_religion">Religion</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_education">Education</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_profession">Profession</td> 
            <td bgcolor="#FFFFFF" name="column-heading_working_status">Working Status</td> 
        <td bgcolor="#FFFFFF" name="column-heading_Marital_status">Marital Status</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_town">Home Town</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_borough">Home Borough</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_city">Home City</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_county">Home County</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_region">Home Region</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_state">Home State</td> 
        <td bgcolor="#FFFFFF" name="column-heading_home_country">Home Country</td> 
        <td bgcolor="#FFFFFF" name="column-heading_contact-page">Contact Page</td> 
        </tr> 
        <?php while($row mysqli_fetch_array($result)){ ?> 
        <tr name="user-details"> 
        <td bgcolor="#FFFFFF" name="submission-number"><?php echo $row['id']; ?></td> 
        <td bgcolor="#FFFFFF" name="browsed-page"><?php echo "<a href='"
                                                              echo 
    $row['browsed_page']; 
                                                              echo 
    "'>"
                                                              echo 
    "Browsed Page</a>"?></td> 
        <td bgcolor="#FFFFFF" name="logging-server-date-&-time"><?php echo $row['date_and_time']; ?></td> 
        <td bgcolor="#FFFFFF" name="username"><?php echo $row['username']; ?></td> 
        <td bgcolor="#FFFFFF" name="gender"><?php echo $row['gender']; ?></td> 
        <td bgcolor="#FFFFFF" name="age-range"><?php echo $row['age_range']; ?></td> 
        <td bgcolor="#FFFFFF" name="religion"><?php echo $row['religion']; ?></td> 
        <td bgcolor="#FFFFFF" name="education"><?php echo $row['education']; ?></td> 
        <td bgcolor="#FFFFFF" name="profession"><?php echo $row['profession']; ?></td> 
        <td bgcolor="#FFFFFF" name="working-status"><?php echo $row['working_status']; ?></td> 
        <td bgcolor="#FFFFFF" name="marital-status"><?php echo $row['marital_status']; ?></td> 
        <td bgcolor="#FFFFFF" name="home-town"><?php echo $row['home_town']; ?></td> 
        <td bgcolor="#FFFFFF" name="home-borough"><?php echo $row['home_borough']; ?></td> 
        <td bgcolor="#FFFFFF" name="home-city"><?php echo $row['home_city']; ?></td> 
        <td bgcolor="#FFFFFF" name="home-county"><?php echo $row['home_county']; ?></td> 
        <td bgcolor="#FFFFFF" name="home-region"><?php echo $row['home_region']; ?></td> 
        <td bgcolor="#FFFFFF" name="home-state"><?php echo $row['home_state']; ?></td> 
        <td bgcolor="#FFFFFF" name="home-country"><?php echo $row['home_country']; ?></td> 
        <td bgcolor="#FFFFFF" name="contact-page"><?php echo "<a href='"
                                                              echo 
    $row['contact_page']; 
                                                              echo 
    "'>"
                                                              echo 
    "Contact Page</a>"?></td> 
        </tr> 
        <?php ?> 
        <tr name="pagination"> 
        <td colspan="19" bgcolor="#FFFFFF"> Result Pages: 
        <?php 
            
    if($rows_num <= $page_size
            { 
                echo 
    "Page 1"
            } 
            else 
            { 
                for(
    $i=1;$i<=$page_count;$i++) 
                echo 
    "<a href=\"{$_SERVER['PHP_SELF']}?page_number={$i}\">{$i}</a>  "
            } 
            
    ?> 
        </td> 
        </tr> 
        <?php } else { ?> 
        <tr> 
        <td bgcolor="FFFFFF">No record found! Try another time.</td> 
        </tr> 
        <?php }?> 
        </table> 
        <br> 
        <br> 
        <center><span style="font-weight: bold;"><?php echo $site_name?> Users' Browsing Histories in <?php echo $server_time?> time.</span></center> 
        <br> 
        <br> 
    </div> 
    <br> 
    </body> 
    </html> 
    <?php 

    ?>
    PREP STMT
    PHP Code:
    <?php  

    //Required PHP Files.  
    include 'config.php';  
    include 
    'header.php';  

    //Check if User is already logged-in or not. Get the login_check() FUNCTION to check.  
    if (login_check() === FALSE)  

        
    //Redirect User to Log-in Page after 2 secs.  
        
    header("refresh:2; url=login.php");  
        exit();  
    }  
    else  
    {  
        
    $user $_SESSION["user"];  
         
        
    $id $_SESSION["id"];  
        
    $account_activation_status $_SESSION["account_activation_status"];  
        
    $id_video_verification_status $_SESSION["id_video_verification_status"];  
        
    $id_video_verification_url $_SESSION["id_video_verification_url"];  
        
    $sponsor_username $_SESSION["sponsor_username"];  
        
    $recruits_number $_SESSION["recruits_number"];  
        
    $on_day_number_on_7_days_wish_list $_SESSION["on_day_number_on_7_days_wish_list"];  
        
    $primary_website_domain $_SESSION["primary_website_domain"];  
        
    $primary_website_email $_SESSION["primary_website_email"];  
        
    $username $_SESSION["username"];  
        
    $first_name $_SESSION["first_name"];  
        
    $middle_name $_SESSION["middle_name"];  
        
    $surname $_SESSION["surname"];  
        
    $gender $_SESSION["gender"];  
        
    $age_range $_SESSION["age_range"];  
        
    $religion $_SESSION["religion"];  
        
    $marital_status $_SESSION["marital_status"];  
        
    $working_status $_SESSION["working_status"];  
        
    $profession $_SESSION["profession"];  
         
        
    $recipient_username $user

        
    ?>  
        <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional/EN">  
        <html>  
        <head>  
        <meta content="text/html; charset=ISO-8859-1"  http-equiv="content-type">  
        <title><?php $user ?>Notices in <?php $server_time ?> time.</title> 
        </head>  
        <body>  
        <br>  
        <center><span style="font-weight: bold;"><?php $user ?>Notices in <?php $server_time ?> time.</span></center>  
        <br>  
        <br>      
    <?php  
        
    if (!$conn

        
    $error mysqli_connect_error(); 
        
    $errno mysqli_connect_errno(); 
        print 
    "$errno$error\n"
        exit(); 

        
    $query "SELECT id,date_and_time,recipient_username,sender_username,notice FROM notices WHERE recipient_username = ?"

    if (
    $stmt mysqli_prepare($conn$query)) { 

        
    /* bind param */ 
        
    mysqli_stmt_bind_param($stmt,'s',$recipient_username);     
        
    /* execute statement */ 
        
    mysqli_stmt_execute($stmt);   
        
    /* bind result variables */ 
        
    $result mysqli_stmt_bind_result($stmt,$id,$date_and_time,$recipient_username,$sender_username,$notice);     
        
    mysqli_stmt_store_result($stmt);      
        
    $rows_num mysqli_stmt_num_rows($stmt); 
        
    printf("Result set has %d rows.\n",$rows_num); 
       


        
    $page_count 10;  
        
    $page_size ceil($rows_num $page_count);  
        
    //Get the Page Number, Default is 1 (First Page)  
        
    $page_number $_GET["page_number"];  
        if (
    $page_number == ""$page_number 1;  
            
    $offset = ($page_number -1) * $page_size;  
             
            
    $query .= " limit {$offset},{$page_size}";  
            
    $result_2 mysqli_query($conn,$stmt); 
            
    //$result = mysqli_stmt_bind_result($stmt,$id,$date_and_time,$recipient_username,$sender_username,$notice);  
            
    mysqli_stmt_store_result($stmt);   
            
    $rows_num mysqli_stmt_num_rows($stmt); 
        
    ?>  
        <table width="1500" border="0" cellpadding="5" cellspacing="2" bgcolor="#666666">  
        <?php if($rows_num) {?>  
        <tr name="headings">  
        <td bgcolor="#FFFFFF" name="column-heading_submission-number">Submission Number</td>  
        <td bgcolor="#FFFFFF" name="column-heading_logging-server-date-&-time">Date & Time in <?php $server_time ?></td>  
        <td bgcolor="#FFFFFF" name="column-heading_to">To</td>  
        <td bgcolor="#FFFFFF" name="column-heading_from">From</td>  
        <td bgcolor="#FFFFFF" name="column-heading_notice">Notice</td>  
        </tr>  
         
        <?php while(mysqli_stmt_fetch($stmt)){ ?>      
        <tr name="user-details">  
        <td bgcolor="#FFFFFF" name="submission-number"><?php printf("%s"$id); ?></td>  
        <td bgcolor="#FFFFFF" name="logging-server-date-and-time"><?php printf("%s"$date_and_time); ?></td>  
        <td bgcolor="#FFFFFF" name="recipient_username"><?php printf("%s"$recipient_username); ?></td>  
        <td bgcolor="#FFFFFF" name="sender_username"><?php printf("%s"$sender_username); ?></td>  
        <td bgcolor="#FFFFFF" name="notice"><?php printf("%s"$notice); ?></td>  
        </tr>  
        <?php ?>  
        <tr name="pagination">  
        <td colspan="10" bgcolor="#FFFFFF"> Result Pages:  
        <?php  
         
        $rows_num 
    mysqli_stmt_num_rows($stmt); 
            if(
    $rows_num <= $page_size)  
            {  
                echo 
    "Page 1";   
            }  
            else  
            {  
                for(
    $i=1;$i<=$page_count;$i++)  
                echo 
    "<a href=\"{$_SERVER['PHP_SELF']}?page_number={$i}\">{$i}</a>  ";  
            }      
            
    ?>      
        </td>  
        </tr>  
        <?php } else { ?>  
        <tr>  
        <td bgcolor="FFFFFF">No record found! Try another time.</td>  
        </tr>  
        <?php }?>  
        </table>  
        <br>  
        <br>  
        <center><span style="font-weight: bold;"><?php $user ?>Notices in <?php $server_time ?> time.</span></center>  
        <br>  
        <br>  
    </div>  
    <br>  
    <br> 
    </body>  
    </html>  
    <?php  

    // Free result set 
    mysqli_stmt_free_result($stmt); 

    //close statement 
    mysqli_stmt_close($stmt); 


    //close connection 
    mysqli_close($conn); 

    ?>
    You know what ? Even though I managed to get the results from row printed, on every page the same results are getting printed! Why is not the $offset working ?
    Last edited by UniqueIdeaMan; March 12th, 2018 at 10:42 AM.
  6. #19
  7. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,950
    Rep Power
    4554
    If you'd stop being so ignorant and actually learn to read the manual, it gives you the answer in the first line on each page.

    mysqli_fetch_array — Fetch a result row as an associative, a numeric array, or both

    mysqli_stmt_fetch — Fetch results from a prepared statement into the bound variables


    -John

    Comments on this post

    • UniqueIdeaMan agrees : Giving REP for pointing the obvious out and bringingthem to my attention. Keep it up like this!
    -- Cigars, whiskey and wild, wild women. --
  8. #20
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    845
    Rep Power
    0
    Originally Posted by Sepodati
    If you'd stop being so ignorant and actually learn to read the manual, it gives you the answer in the first line on each page.

    mysqli_fetch_array Fetch a result row as an associative, a numeric array, or both

    mysqli_stmt_fetch Fetch results from a prepared statement into the bound variables


    -John
    Thanks John!


    Sorry, I read about this but forgot:
    mysqli_fetch_array Fetch a result row as an associative, a numeric array, or both

    I know when "stmt" is involved, it means PREP STMT.
    This, it should have been obvious to me that, it fetches result from PREP STMT since the word "stmt" is involved and dsMadismad or whatever his username is, did teach me about the classes briefly.
    And so, this should have been obvious to me:
    mysqli_stmt_fetch Fetch results from a prepared statement into the bound variables

    Anyway, thanks for being blunt. I hope I remember all this. You know how it is, when you've learnt something new then your rememberance is RAW.
    The more I practice the more it will SINK IN.
    Last edited by UniqueIdeaMan; March 12th, 2018 at 11:21 AM.
  10. #21
  11. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,950
    Rep Power
    4554
    Nothing is sinking in, but carry on...

    Comments on this post

    • UniqueIdeaMan agrees : I'll even give you a REP for that. Ok, I will carry on but bear with me.
    -- Cigars, whiskey and wild, wild women. --
  12. #22
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    845
    Rep Power
    0
    Johny Sep,

    Johny Depp just came to mind. May I call you that ? Lol! I'm sensing Benanamen would be at my throat for asking this as he thinks I have a bad habit of giving people "pet names" as his friend Tango Force claimed that codingforums.com (British forum, I think).
    Anyway, Php Master & Guru & Pro,

    Can you be so kind to drag my head out of the puddle I am drowning in tonight ?
    Why is the OFFSET on the pagination malfunctioning ? You see, every page shows the same result !!!
    I spoke to soon few hrs ago when I said this code was working, without properly testing it. But can you blame me. I was in a rush to go out.
    PHP Code:
    <?php  

    //Required PHP Files.  
    include 'config.php';  
    include 
    'header.php';  

    //Check if User is already logged-in or not. Get the login_check() FUNCTION to check.  
    if (login_check() === FALSE)  

        
    //Redirect User to Log-in Page after 2 secs.  
        
    header("refresh:2; url=login.php");  
        exit();  
    }  
    else  
    {  
        
    $user $_SESSION["user"];  
         
        
    $id $_SESSION["id"];  
        
    $account_activation_status $_SESSION["account_activation_status"];  
        
    $id_video_verification_status $_SESSION["id_video_verification_status"];  
        
    $id_video_verification_url $_SESSION["id_video_verification_url"];  
        
    $sponsor_username $_SESSION["sponsor_username"];  
        
    $recruits_number $_SESSION["recruits_number"];  
        
    $on_day_number_on_7_days_wish_list $_SESSION["on_day_number_on_7_days_wish_list"];  
        
    $primary_website_domain $_SESSION["primary_website_domain"];  
        
    $primary_website_email $_SESSION["primary_website_email"];  
        
    $username $_SESSION["username"];  
        
    $first_name $_SESSION["first_name"];  
        
    $middle_name $_SESSION["middle_name"];  
        
    $surname $_SESSION["surname"];  
        
    $gender $_SESSION["gender"];  
        
    $age_range $_SESSION["age_range"];  
        
    $religion $_SESSION["religion"];  
        
    $marital_status $_SESSION["marital_status"];  
        
    $working_status $_SESSION["working_status"];  
        
    $profession $_SESSION["profession"];  
         
        
    $recipient_username $user

        
    ?>  
        <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional/EN">  
        <html>  
        <head>  
        <meta content="text/html; charset=ISO-8859-1"  http-equiv="content-type">  
        <title><?php $user ?>Notices in <?php $server_time ?> time.</title> 
        </head>  
        <body>  
        <br>  
        <center><span style="font-weight: bold;"><?php echo "$user "?>Notices in <?php echo "$server_time "?> time.</span></center>  
        <br>  
        <br>      
    <?php  
        
    if (!$conn

        
    $error mysqli_connect_error(); 
        
    $errno mysqli_connect_errno(); 
        print 
    "$errno$error\n"
        exit(); 

        
    $query "SELECT id,date_and_time,recipient_username,sender_username,notice FROM notices WHERE recipient_username = ?"

    if (
    $stmt mysqli_prepare($conn$query)) { 

        
    /* bind param */ 
        
    mysqli_stmt_bind_param($stmt,'s',$recipient_username);     
        
    /* execute statement */ 
        
    mysqli_stmt_execute($stmt);   
        
    /* bind result variables */ 
        
    $result mysqli_stmt_bind_result($stmt,$id,$date_and_time,$recipient_username,$sender_username,$notice);     
        
    mysqli_stmt_store_result($stmt);      
        
    $rows_num mysqli_stmt_num_rows($stmt); 
        
    printf("Result set has %d rows.\n",$rows_num); 
       


        
    $page_count 10;  
        
    $page_size ceil($rows_num $page_count);  
        
    //Get the Page Number, Default is 1 (First Page)  
        
    $page_number $_GET["page_number"];  
        if (
    $page_number == ""$page_number 1;  
            
    $offset = ($page_number -1) * $page_size;  
             
            
    $query .= " limit {$offset},{$page_size}";  
            
    $result mysqli_stmt_bind_result($stmt,$id,$date_and_time,$recipient_username,$sender_username,$notice);  
            
    mysqli_stmt_store_result($stmt);   
            
    $rows_num mysqli_stmt_num_rows($stmt); 
        
    ?>  
        <table width="1500" border="0" cellpadding="5" cellspacing="2" bgcolor="#666666">  
        <?php if($rows_num) {?>  
        <tr name="headings">  
        <td bgcolor="#FFFFFF" name="column-heading_submission-number">Submission Number</td>  
        <td bgcolor="#FFFFFF" name="column-heading_logging-server-date-&-time">Date & Time in <?php $server_time ?></td>  
        <td bgcolor="#FFFFFF" name="column-heading_to">To</td>  
        <td bgcolor="#FFFFFF" name="column-heading_from">From</td>  
        <td bgcolor="#FFFFFF" name="column-heading_notice">Notice</td>  
        </tr>  
         
        <?php while(mysqli_stmt_fetch($stmt)){ ?>  //Line 99. Should I amend this line ? If so, then to what ?
        <tr name="user-details">  
        <td bgcolor="#FFFFFF" name="submission-number"><?php printf("%s"$id); ?></td>  
        <td bgcolor="#FFFFFF" name="logging-server-date-and-time"><?php printf("%s"$date_and_time); ?></td>  
        <td bgcolor="#FFFFFF" name="recipient_username"><?php printf("%s"$recipient_username); ?></td>  
        <td bgcolor="#FFFFFF" name="sender_username"><?php printf("%s"$sender_username); ?></td>  
        <td bgcolor="#FFFFFF" name="notice"><?php printf("%s"$notice); ?></td>  
        </tr>  
        <?php ?>  
        <tr name="pagination">  
        <td colspan="10" bgcolor="#FFFFFF"> Result Pages:  
        <?php  
         
        $rows_num 
    mysqli_stmt_num_rows($stmt); 
            if(
    $rows_num <= $page_size)  
            {  
                echo 
    "Page 1";   
            }  
            else  
            {  
                for(
    $i=1;$i<=$page_count;$i++)  
                echo 
    "<a href=\"{$_SERVER['PHP_SELF']}?page_number={$i}\">{$i}</a>  ";  
            }      
            
    ?>      
        </td>  
        </tr>  
        <?php } else { ?>  
        <tr>  
        <td bgcolor="FFFFFF">No record found! Try another time.</td>  
        </tr>  
        <?php }?>  
        </table>  
        <br>  
        <br>  
        <center><span style="font-weight: bold;"><?php echo "$site_name $user "?>User's Notices in <?php echo $server_time?> time.</span></center> 
        <br>  
        <br>  
    </div>  
    <br>  
    <br> 
    </body>  
    </html>  
    <?php  

    // Free result set 
    mysqli_stmt_free_result($stmt); 

    //close statement 
    mysqli_stmt_close($stmt); 


    //close connection 
    mysqli_close($conn); 

    ?>
    Ignore outdated html for now.

    EDIT:
    I guess I have to amend this in line 99:
    PHP Code:
    <?php while(mysqli_stmt_fetch($stmt)){ ?>
    Correct ?
    Last edited by UniqueIdeaMan; March 12th, 2018 at 12:13 PM.
  14. #23
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    845
    Rep Power
    0
    Php Folks,

    I have a question regarding this following line:
    PHP Code:
    <?php while(mysqli_stmt_fetch($stmt))
    Correct me if I am wrong, but does it not mean:
    Keep on binding each row value and display them on the page in a loop until all rows have been fetched.
    Did I understand correct ?
    So, if the tbl looks like this:

    Username|Pass|
    user1|pass1
    user2|pass2

    Then there would be 2 loops. On the 1st loop, PREP STMT would bind the 1st row:
    user1|pass1

    Then, on the 2nd loop, PREP STMT would bind the 2nd row:
    user2|pass2

    Is this correct ? If I understand this part well then I guess I can solve the issue.

    Cheers!
  16. #24
  17. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,950
    Rep Power
    4554
    Why is the OFFSET on the pagination malfunctioning ?
    Because you have no ****ing clue what you're doing. If I gave you code that drew a ****, you'd happily copy-and-paste it into your code because that's all you do.


    Can you even outline what you want to happen, in psudo-code? Give us five or six steps that actually demonstrate what you want to happen. This isn't about code, it's about understanding what you even need to do. The answer is not copy-and-paste.

    Why isn't the "offset" query working? Because, for starters, you're not even ****ing running the query.

    -John
    -- Cigars, whiskey and wild, wild women. --
  18. #25
  19. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,950
    Rep Power
    4554
    Originally Posted by UniqueIdeaMan
    Is this correct ?
    Didn't we just cover this?

    mysqli_stmt_fetch Fetch results from a prepared statement into the bound variables


    If I understand this part well then I guess I can solve the issue.
    lol... doubtful.
    -- Cigars, whiskey and wild, wild women. --
  20. #26
  21. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    845
    Rep Power
    0
    Originally Posted by Sepodati
    lol.... No, I do not. You have to be ****ing with us, right? Please??

    Now, you've created a bit of html in a loop. Good on you for that. How do you plan on processing the requst, when page 3 is requested, for example? How are you showing results 21-30, assuming 10 per page.

    You have no logic handling that.

    ****.
    Ok. I get your point. But, how does the concatenation handle that ? Strange.
    Anyway, replying to an old post I missed.
  22. #27
  23. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2017
    Posts
    845
    Rep Power
    0
    Originally Posted by Sepodati
    Because you have no ****ing clue what you're doing. If I gave you code that drew a ****, you'd happily copy-and-paste it into your code because that's all you do.


    Can you even outline what you want to happen, in psudo-code? Give us five or six steps that actually demonstrate what you want to happen. This isn't about code, it's about understanding what you even need to do. The answer is not copy-and-paste.

    Why isn't the "offset" query working? Because, for starters, you're not even ****ing running the query.

    -John
    I tell you what. Let's play a quiz type of game. You mention that, if you give me the code then I'll jus copy & paste and won't really learn anything.
    How-about we play a little game to help us newbies learn faster ?
    You can give us 3 code samples where one is full of error code, another full of bad coding practice even no errors get shown and another sample that is like a jigsaw puzzle. The last one would have all the correct code showing no errors. But, the codes would be rearranged and using our logic we would have to put the pieces together. You may throw in unwanted lines of garbage code just to try to trip us up. Our task would be to weed-out the wheat from the chaff. And not only that. Desing the sample in a way that it would work in many ways. One way it would work but not too good. Meaning, the code would put strain on the db or cpu. the other way would work perfect and fast (fast processor).
    Now, if we manage to give you the work in perfect order then you give us 1st class rating. Else, 2nd class (providing we give you a working sample). Good idea ?
    This is a good way to learn and get more experienced. Good brain exercise.

    @anybody: If anybody else deem my idea to be good then you too are welcome to build such php games. Hell, you might even sell php jigsaw puzzle packs one day after you've become good at building such.
    People, I knew I was good at dreaming up cool ideas. But, I also know I'm a crap programmer. All this can change with the likes of these php jigsaw puzzle games!
    You know what ? Once I manage to master Python, I might aswell build a jigsaw puzzle solving site website. I mean it!
    Last edited by UniqueIdeaMan; March 15th, 2018 at 05:11 PM.
  24. #28
  25. Lord of the Dance
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Oct 2003
    Posts
    4,170
    Rep Power
    2011
    Originally Posted by UniqueIdeaMan
    another full of bad coding practice even no errors get shown
    No more of this. You should be able to find a lot of this on the internet already through searching.
    Otherwise, we can use a lot of time the next couple of months to explain why it suddenly stopped working "for no reason", for those who just did the copy-paste practice.

    Originally Posted by UniqueIdeaMan
    You know what ? Once I manage to master Python, I might aswell build a jigsaw puzzle solving site website. I mean it!
    Well, once you manage to master Logic, you might actually be able to build up something decent.
  26. #29
  27. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2017
    Location
    Worldwide
    Posts
    48
    Rep Power
    45
    Dude (op), your constant sideways begging for code is seriously played out. I am surprised anybody even answers you anymore.
  28. #30
  29. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,950
    Rep Power
    4554
    Originally Posted by benanamen
    Dude (op), your constant sideways begging for code is seriously played out. I am surprised anybody even answers you anymore.
    Meh... it's like the only thing going on around here. in the old days, this would have been over and done with in the first week.
    -- Cigars, whiskey and wild, wild women. --

IMN logo majestic logo threadwatch logo seochat tools logo