Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Php Helped Needed

    I am doing a code in php that shows total sales , code is working fine but it shows previous date , not todays date , i want it like to show the todays date with the today sale up till now ? how can i ? Please Help

    <?php

    $host = 'localhost';
    $user = 'root';
    $passwd = '';
    $database = 'p_database';
    $connect = mysql_connect($host,$user,$passwd) or die("could not connect to database");

    $query = "SELECT DATE(order_time) AS date, SUM(Quantity) AS totalsales
    FROM ss_orders,ss_ordered_carts
    GROUP BY date
    LIMIT 0 , 30";
    mysql_select_db($database,$connect);
    $result = mysql_fetch_assoc(mysql_query($query));
    print_r($result);
    ?>

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,290
    Thanks
    23
    Thanked 611 Times in 610 Posts
    Your in the wrong section. This is for code that works. This is a MySQL thing and belongs here http://codingforums.com/mysql/

    But when you invoke two tables
    Code:
    FROM ss_orders,ss_ordered_carts
    you have to show their relationship with a WHERE clause and the SELECT should also clarify where each column comes from.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    Tags for this Thread

    Posting Permissions

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