extract date from timestamp and compare

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • omerbutt
    Contributor
    • Nov 2006
    • 638

    extract date from timestamp and compare

    hi there i am making a page where customer can edit his current order, the tools i am using are mysql and php
    i am using 2 tables for this
    1.rage_uk_bulk_ order
    2.rage_uk_bulk_ order_products

    i have the time stamp in the 1st table rage_uk_bulk_or der and all the other information in the 2nd table iall is going fine it is fetching all the records for the current user/customer but i want to display only those orders from the table that the user has ordered today not those of the previous for that i had to compare todays date with the time stamp saved in the 1st table and pick all those records and display them buit i am not getting it in the right format here is my query
    THE ERROR CODE
    [CODE=ERROR]
    Parse error: syntax error, unexpected ',' in D:\Server\htdoc s\borialas\edit _bill.php on line 42
    [/CODE]
    the above line 42 is the line no 27 here on this post
    [PHP]
    if(isset($_GET['a']) && isset($_GET['a1'])){
    $bulk_odr_prod_ id=substr(base6 4_decode($_GET['a']),17);
    $odr_bulk_id=su bstr(base64_dec ode($_GET['a1']),12);
    }
    $tstamp=time();
    $tstamp=date("Y-m-d",$tstamp);
    $mem_id="2";
    $str_ordEdit="S ELECT
    rage_uk_bulk_or der.odr_bulk_st amp,
    rage_uk_bulk_or der_products.bu lk_odr_prod_nam e,
    rage_uk_bulk_or der_products.bu lk_odr_prod_pri ce,
    rage_uk_bulk_or der_products.bu lk_odr_prod_qty ,
    rage_uk_bulk_or der_products.bu lk_odr_prod_len gth,
    rage_uk_bulk_or der_products.bu lk_odr_prod_wei ght,
    rage_uk_bulk_or der_products.bu lk_odr_prod_ver sion,
    rage_uk_bulk_or der_products.bu lk_odr_prod_tot al,
    rage_uk_bulk_or der_products.od r_bulk_id,
    rage_uk_bulk_or der_products.bu lk_odr_prod_id,
    rage_uk_bulk_or der_products.pr o_id
    FROM
    rage_uk_bulk_or der_products,ra ge_uk_bulk_orde r
    WHERE
    rage_uk_bulk_or der_products.bu lk_odr_prod_id= '$bulk_odr_prod _id'
    and
    rage_uk_bulk_or der_products.od r_bulk_id='$odr _bulk_id'
    and
    '$tstamp'=".dat e("'Y-m-d'".,."'rage_uk _bulk_order.odr _bulk_stamp'".) ."";
    //echo $str_ordEdit;
    $res_ordEdit=my sql_query($str_ ordEdit) or die(mysql_error ().'<br />'.$str_ordEdit );
    [/PHP]
    thanks for any help in advance,
    regards,
    omer
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    What are you trying to do in that line?
    Incorporating the PHP date function into the MySQL query?

    That won't work. PHP will need the actual value before it can format it, not just the column name in the MySQL query.

    Try using the MySQL DATE_FORMAT function instead.

    Comment

    Working...