Results 1 to 6 of 6

Thread: PayDate

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2024
    Posts
    2

    PayDate

    Hello Guys,

    I'm using this code to show all orders that have been placed in the database, my question is i was wondering how i can go about getting to show by the earliest day so for example i have 3 records like 29/10/2024 and 23/10/2024 and 27/10/2024 and the field in the mysqli database is called PayDate show do i get it to show the dates like the above but in order using the code below.

    PHP Code:

    <?php include('styles/top.php'); ?>


        
         <div id="full">
        
            <div id="view_box">
                <ul>
                    <li><img src="images/1.png" /></li>
                    <!-- <li><img src="pics/2.jpg" /></li> -->
                    <!-- <li><img src="pics/3.jpg" /></li> -->
                </ul>
            </div>
            
            <div id="button">
                <ul>
                    <!-- <li><button class="button" scroll_value="0">*</button></li> -- >
                    <!-- <li><button class="button" scroll_value="600">*</button></li> -->
                    <!-- <li><button class="button" scroll_value="1200">*</button></li> -->
                </ul>
            </div>
            <hr /><br />
            
           <?php
            
    //error_reporting(0);
             
            
    if (($user_level !=1) && ($user_level !=2)){
                echo 
    "No Access Allowed";
            } else {
            
            
            if(isset(
    $_GET['page'])){
                
    $page $_GET['page'];
            } else {
                
    $page 1;
            }
            
            if(
    $page == '' || $page == 1){
                
    $page1 0;
            } else {
                
    $page1 = ($page*4)-4;
            }
            
            
    $sql "SELECT * FROM orders Where orderby= '$username' AND Status='paid' LIMIT ".$page1.", 4";
            
    //$sql = 'SELECT * FROM orders LIMIT '.$page1.', 4';
            
    $data $con->query($sql);
            
            
    ?>
            
            <h3>View Orders</h3>
            
                    <table border=1">
                    <tr>
                        <th>FULL NAME </th>
                        <th>DATE GOT </th>
                        <th>PAY DATE</th>
                        <th>MONEY DUE</th>
                        <th>UPDATE ORDER STATUS</th>
                    </tr>
                    
                    <tr>
                            <td>&nbsp;</td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                    
                    <?php
                    
        
                    $totmoney 
    0;
                    
    $strmoney "";
                    
                    while (
    $myrow mysqli_fetch_array($data))
                    {
                        
    $strmoney $myrow["Money"];
                        
    $strmoney str_replace(',','',$strmoney);
                        
                        if(
    is_numeric($strmoney))
                        {
                            
    settype($strmoney"float");
                            
    $strmoney number_format($strmoney2);
                        }
                        echo 
    "<TR><TD><a href=\"_view.php?id=".$myrow['id']."\">".$myrow["FullName"]."</A>&nbsp;</TD><TD>".$myrow["GotDate"]."&nbsp;</TD><TD>".$myrow["PayDate"]."&nbsp;</TD><TD>&pound;".$strmoney."&nbsp;</TD>";
                        echo 
    "<TD><center><a href=\"edit_order.php?id=".$myrow['id']."\"><img class=\"displayed\" alt=\"View\" src=\"images/edit.png\" width=\"175\" height=\"25\" /></a></center></TD>";
                        echo 
    "</TR>";
                        
                        
    $totmoney $totmoney + (int)$myrow["Money"];
                    }
                    
                    
                    
    ?>
                    
                    
                       <tr>
                            <td>&nbsp;</td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                    
                    <tr>
                            <td>&nbsp;</td>
                            <td>TOTAL DUE</td>
                            <td>&pound;<?=number_format($totmoney2);?>&nbsp;</td>
                            <td></td>
                            <td></td>
                        </tr>
                              
                </table>
                
                
                <br />  
           
           <?php
          
            $sql 
    "SELECT * FROM orders Where orderby= '$username' AND Status='Layon'";
            
    $data $con->query($sql);
            
    $records $data->num_rows;
            
    $records_pages $records/4;
            
    $records_pages ceil($records_pages);
           
            
    $prev $page-1;
            
    $next $page+1;
            
            echo 
    '<ul class="paganation">';
            
            if(
    $prev >= 5){
                echo 
    '<li><a href="?page=1">First Page</a></li>';
            }
            
            if(
    $prev >=1){
                echo 
    '<li><a href="?page='.$prev.'">Previous</a></li>';
            }
            
            
            if(
    $records_pages >= ){
                for(
    $r=1$r <= $records_pages$r++){
                    
    $active $r == $page 'class="active"' '';
                    echo 
    '<li><a href="?page='.$r.'" '.$active.'>'.$r.'</a></li>';
                }
            }
            
            
            if(
    $next <= $records_pages && $records_pages >= 2){
                echo 
    '<li><a href="?page='.$next.'">Next</a></li>';
            }
            
            if(
    $page != $records_pages && $records_pages >= 5){
                echo 
    '<li><a href="?page='.$records_pages.'">Last Page</a></li>';
            }
            
            echo 
    '</ul>';
           
           
    ?>
                   
            <?php
            
    }
            
    ?>
            
            
           
        </div>

    <?php include('styles/bottom.php'); ?>

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,677

    Re: PayDate

    Add an ORDER BY PayDate to your sql query

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2024
    Posts
    2

    Re: PayDate

    hello ive tried
    Code:
    $sql = "SELECT * FROM orders Where ORDER BY paydate customer_name= '$customer_name' AND Status='paid' LIMIT ".$page1.", 4";
    all the records remove from the page.

    also i have said my field in the mysqli database is a VARCHAR(50) and used the date format like

    29/10/2024

  4. #4
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,784

    Re: PayDate

    *sigh*

    Learn SQL

    Spot the Mistake
    Code:
    SELECT * FROM orders Where ORDER BY paydate customer_name= '$customer_name' AND

    SELECT SomeFields
    FROM FromTable
    WHERE Condition
    ORDER BY OrderingColumns
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,677

    Re: PayDate

    Still not going to sort right because
    my field in the mysqli database is a VARCHAR(50) and used the date format like

    29/10/2024

    (cries in DATETIME fields)


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,784

    Re: PayDate

    Quote Originally Posted by techgnome View Post
    Still not going to sort right because



    (cries in DATETIME fields)


    -tg
    Didn't even see that one....
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width