Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Modifying tpl_header.php with new link to pass cust_id to new page

Modifying tpl_header.php with new link to pass cust_id to new page

Locked

Views: 2,809

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
23 Jun 2008, 3:18 PM
#1
customgt avatar

customgt

New Zenner

Join Date:
Jan 2008
Posts:
8
Plugin Contributions:
0

Modifying tpl_header.php with new link to pass cust_id to new page

<li><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">'; ?><?php 
echo HEADER_TITLE_CATALOG; ?></a></li>
<?php if ($_SESSION['customer_id']) { ?>
    <li><a href="<?php echo zen_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>"><?php 
echo HEADER_TITLE_LOGOFF; ?></a></li>


PUT LINE HERE FOR MY MOVIES


    <li><a href="<?php echo zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>"><?php 
echo HEADER_TITLE_MY_ACCOUNT; ?></a></li>

<li><a href="<?php echo zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>"><?php 
echo HEADER_TITLE_MY_ACCOUNT; ?></a></li>

<?php
      } else {
        if (STORE_STATUS == '0') {
?>
    <li><a href="<?php echo zen_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php 
echo HEADER_TITLE_LOGIN; ?></a></li>
<?php } } ?>

I want to add a link that says "My Movies" next to the Log Out link.
The "My Movies" page is a custom page i made in php/mysql.
Ive noted above where the link should go, but i do not know all this Zen Cart stuff that good. When they click the link, for "My Movies", it needs to pass the customer_id of the user currently logged in to the php page I created.

Can someone help me with the line of code to do this, i usually do it with a form and button to pass a variable to another php page, never done it using just a text link. (and im a novice php programmer anyways)

thanks!!

24 Jun 2008, 4:52 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Modifying tpl_header.php with new link to pass cust_id to new page

Replace:

PUT LINE HERE FOR MY MOVIES

with:

<a href="http://THE_URL_GOES_HERE?cust_id=<?php echo $_SESSION['customer_id']; ?>" target="_blank">Click here for Movies Page</a>

24 Jun 2008, 8:14 PM
#3
customgt avatar

customgt

New Zenner

Join Date:
Jan 2008
Posts:
8
Plugin Contributions:
0

Re: Modifying tpl_header.php with new link to pass cust_id to new page

Awesome that works perfect!

One last thing i need to finish this,

Its running a mysql search query for everything in the orders table where customers_ID = whatever:

$result = mysql_query("SELECT * FROM orders WHERE
customers_id=$cust_id");

But i only want to select orders for that cust_id that are within 48 hours of the current date. The column in the orders table is "date_purchased"

It is formatted like: 2008-06-19 14:25:01

I have no idea how to go about doing that. Maybe if it was in unix time i could figure it out, but in the format that it is in the database im not sure....

If you dont know please let me know also and i will restart this thread with an appropriate title.

thanks again!

ps...this is a vod solution im doing...zen cart is an awesome OS site for things that need a shipping cart and payment gateway. I will try to release this as a module or whatever when its done.

25 Jun 2008, 3:08 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Modifying tpl_header.php with new link to pass cust_id to new page

Add to your WHERE clause something like this:

AND date_purchased >= DATE_SUB(CURDATE(), INTERVAL 2 DAY);

Ref: http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

25 Jun 2008, 2:26 PM
#5
customgt avatar

customgt

New Zenner

Join Date:
Jan 2008
Posts:
8
Plugin Contributions:
0

Re: Modifying tpl_header.php with new link to pass cust_id to new page

Thanks I got that to work.

Here is my whole line of code for anyone needing it in the future.

$result = mysql_query("SELECT * FROM orders WHERE customers_id=$cust_id 
AND date_purchased >= DATE_SUB(CURRENT_DATE(), INTERVAL 2 DAY)");

The manual said "CURRENT_DATE, CURDATE(), CURRENT_DATE()"

If it returned zero rows it threw an error on the page.
I had to put all my code after it in if/else for if the rownumbers of $result >= 0 or not...

if(mysql_num_rows($result) > 0) {

} else {

}