Displaying expire_date in a php page

Discussion in 'Customization & add-ons' started by Thomdom, Nov 30, 2005.

  1. Thomdom

    Thomdom New Member

    Joined:
    Oct 5, 2005
    Messages:
    7
    Hi,
    wondering how to go about displaying the membership expire_date from the payments table in a php page?

    I have successfully displayed data from the members table in a page but have had no luck displaying anything from the payments table.

    Any ideas?

    Mark
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Mark,
    you need some PHP programming knowledge to do that.

    Add the following to very top of your php page:
    PHP:
    <?php session_start(); ?>
    then, where you need to display expiration date, insert the following:
    PHP:
    <?php
    $expire 
    "---"// not defined
    foreach ($_SESSION['_amember_subscriptions'] as $p){
       if (
    $p['completed']) $expire $p['expire_date'];
    }
    print 
    "EXPIRE=" $expire;
    ?>
  3. Thomdom

    Thomdom New Member

    Joined:
    Oct 5, 2005
    Messages:
    7
    Thanks Alex,

    That worked great! Can I ask how I can display the date in dd/mm/yyyy format?

    I'd also like to be able to display the type of membership the user is signed up for. Can you tell me the php code for that?

    Thanks again for your excellent support!

    Mark
  4. Thomdom

    Thomdom New Member

    Joined:
    Oct 5, 2005
    Messages:
    7
    Alex,

    Any ideas please?
  5. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    try this
    PHP:
    <?php
    $expire 
    "---"// not defined
    foreach ($_SESSION['_amember_subscriptions'] as $p){
       if (
    $p['completed']) {
             
    $expire $p['expire_date'];
       }
    }
    print 
    "<br>EXPIRE=" date('d/m/Y'strtotime($expire));

    $pr_list $_SESSION['_amember_products'];
    $pr $pr_list[count($pr_list)-1]['title'];
    print 
    "<br>PRODUCT=" $pr;
    ?> 
  6. 123Marketing

    123Marketing Member

    Joined:
    Jun 4, 2005
    Messages:
    138
    Expire date conversion to Smarty

    Can you show us how to convert the code above to Smarty?
  7. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    just put
    {php}
    and
    {/php}
    around php code and it wil work. session_start is not needed in this case.
  8. 123Marketing

    123Marketing Member

    Joined:
    Jun 4, 2005
    Messages:
    138
    Hmmm...

    ... when I converted to Smarty, I get this error:

    Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/xxxxxxxx/public_html/templates_c/%%94^948^948C8F69%%aMember-cheat-sheet.tpl.php on line 124
  9. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
  10. mccullah

    mccullah New Member

    Joined:
    Aug 14, 2008
    Messages:
    2
    Solution?

    I have the same problem, what was the solution?

    (I'm trying to display expiration on profile.html page).
  11. mccullah

    mccullah New Member

    Joined:
    Aug 14, 2008
    Messages:
    2
    Fixed problem

    This is now working for me. There were two things that caused the parse error:

    1) When you put the {php} and {/php} around the code, be sure to remove the <?php> and <?> tags.

    2) Make sure the php code is properly formatted. My HTML program (Dreamweaver) when I cut&paste the php code to another location in the file put my 'foreach' line on the same line as the tag comment, ie from the example code in an earlier post above:

    $expire = "---"; // not defined foreach ($_SESSION['_amember_subscriptions'] as $p){
    if ($p['completed']) {
    $expire = $p['expire_date'];
    }
    }

    Make sure the foreach starts on its own line, etc.

Share This Page