| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Data passing between template and PHP file | ||||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() I hope someone can give me some direction with this. I've made a new template with three dropdowns and the bottom two need to be dynamically populated from a table I have added to the database.
tpl file Code:
Code:
Does the year dropdown post the result to the php file as I have it shown? I think I am missing some sort of variable declaration or something even more obvious. How do I get the resulting query back to the tpl file to fill the make dropdown? I believe I'll need to loop through the array to fill that drop down. Is this correct. Sorry for being vague, I'm still trying to get a handle on the templates and Smarty. Thanks. Adam
__________________
Adam X-Cart Gold 4.4.5 - Live X-Cart Gold 4.1.11 - Retired X-Payments 1.0.4 CDSEO Pro EWD Hosting |
|||||||
#2
|
|||||||
|
|||||||
![]() OK here's what I've come up with now. Still nothing. Can someone direct me to ways to troubleshoot this? I don't even know that the year is being posted to the PHP file.
from /skin/mmy.tpl Code:
from main xcart folder: Code:
Are the file locations correct? Am I missing some sort of include? Any help is greatly appreciated. Thanks. Adam
__________________
Adam X-Cart Gold 4.4.5 - Live X-Cart Gold 4.1.11 - Retired X-Payments 1.0.4 CDSEO Pro EWD Hosting |
|||||||
#3
|
|||||||||
|
|||||||||
![]() use event to submit the form
something like this-> <form method="post" action="mmy.php" name="mmysearchform"> <select name="year" style="width: 80%;" onchange="javascript:document.mmysearchform.submit ();"> Quote:
__________________
MercuryMinds Technologies Development Team, Professional X-Cart Design, X-Cart Development, X-Cart Customization Services www.mercuryminds.com X-Cart Mailchimp Ecommerce 360 Plugin/integration module (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) Smasher, a smart search engine for x-cart store (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) One Page Checkout (OPC) - X-Cart module (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) |
|||||||||
#4
|
|||||||||
|
|||||||||
![]() and try to put exit(); in php file to make sure whether the form submitted to corresponding File or not.
__________________
MercuryMinds Technologies Development Team, Professional X-Cart Design, X-Cart Development, X-Cart Customization Services www.mercuryminds.com X-Cart Mailchimp Ecommerce 360 Plugin/integration module (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) Smasher, a smart search engine for x-cart store (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) One Page Checkout (OPC) - X-Cart module (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) |
|||||||||
#5
|
|||||||
|
|||||||
![]() Thanks, now its sending the year to mmy.php but to no surprise it's causing an error that ends up showing the entire php file in the browser.
Can someone give me some direction on how to troubleshoot this? Any help is greatly appreciated. Thanks. Adam
__________________
Adam X-Cart Gold 4.4.5 - Live X-Cart Gold 4.1.11 - Retired X-Payments 1.0.4 CDSEO Pro EWD Hosting |
|||||||
#6
|
|||||||||
|
|||||||||
![]() Hi,
Please check presence of opening and closing php tag? and just copy and paste the error or provide the error screen shot. Then only it is easy for us to debug. Quote:
__________________
MercuryMinds Technologies Development Team, Professional X-Cart Design, X-Cart Development, X-Cart Customization Services www.mercuryminds.com X-Cart Mailchimp Ecommerce 360 Plugin/integration module (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) Smasher, a smart search engine for x-cart store (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) One Page Checkout (OPC) - X-Cart module (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) |
|||||||||
#7
|
|||||||
|
|||||||
![]() After implementing some of the suggestions and a couple of easy things I found this is what is happening.
php file Code:
Is giving me: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\wamp\www\xcart\mmy.php on line 6 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\wamp\www\xcart\mmy.php on line 8 Now I'm guessing query is not returning any results. Does the query automatically use the last connection to the database? Or is there something I need to change in the connection to get this to work? Thanks again. Adam
__________________
Adam X-Cart Gold 4.4.5 - Live X-Cart Gold 4.1.11 - Retired X-Payments 1.0.4 CDSEO Pro EWD Hosting |
|||||||
#8
|
|||||||||
|
|||||||||
![]() 1.
To establish connection just include this line require "./auth.php"; after this <?php line. 2.If you need to get the list of makeid for this year just use $makelist= func_query("SELECT DISTINCT(makeid),makename FROM iemmy WHERE yearid='$year'"); So,above query will display all the makeid and makename related to your year then use smarty like this $smarty->assign ("makelist", $makelist); 3. in your tpl file use foreach function to list this. Quote:
__________________
MercuryMinds Technologies Development Team, Professional X-Cart Design, X-Cart Development, X-Cart Customization Services www.mercuryminds.com X-Cart Mailchimp Ecommerce 360 Plugin/integration module (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) Smasher, a smart search engine for x-cart store (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) One Page Checkout (OPC) - X-Cart module (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) |
|||||||||
#9
|
|||||||
|
|||||||
![]() So far so good. Now it seems as if the php file is working (ie no errors), but the page goes white and the URL is ...xcart/mmy.php It's like its loading a new page rather than just running the php and returning results. Here's what I have going now.
tpl Code:
php Code:
What I am ultimately trying to do is to pass this query back to the form in my tpl file and populate the second dropdown box with the results. I tried adding a foreach loop to the tpl file to see the array, but the browser screen still went white. I'm extremely grateful for your help. Thanks again. Adam
__________________
Adam X-Cart Gold 4.4.5 - Live X-Cart Gold 4.1.11 - Retired X-Payments 1.0.4 CDSEO Pro EWD Hosting |
|||||||
#10
|
|||||||||
|
|||||||||
![]() ok..
you need to tell your system that which tpl need to display. For that add this in your php file: $smarty->assign ("main", "anynewnamehere"); add the below line in skin1/common_templetes.tpl before "else" condition {elseif $main eq "anynewnamehere"} {include file="your tpl name goes here"} Quote:
__________________
MercuryMinds Technologies Development Team, Professional X-Cart Design, X-Cart Development, X-Cart Customization Services www.mercuryminds.com X-Cart Mailchimp Ecommerce 360 Plugin/integration module (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) Smasher, a smart search engine for x-cart store (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) One Page Checkout (OPC) - X-Cart module (Compatible with X-Cart 4.1.x, 4.2.x, 4.3.x) |
|||||||||
![]() |
|
Thread Tools | Search this Thread |
|
|
|
|||
X-Cart forums © 2001-2020
|