View Single Post
  #1  
Old 12-15-2008, 01:00 PM
 
AMMoyer AMMoyer is offline
 

Senior Member
  
Join Date: Nov 2008
Posts: 150
 

Default Data passing between template and PHP file

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:
{* $Id: mmy.tpl,v 1.0.0.0 2008/12/12 07:58:28 amm Exp $ *} {capture name=menu} <form method="post" action="mmy.php" name="year"> <select name="year" style="width: 80%;"> <option value="" selected="selected">Select Year</option> <option value="2009">2009 <option value="2008">2008 <option value="2007">2007 <option value="2006">2006 <option value="2005">2005 <option value="2004">2004 </select><br> <form method="post" action="mmy.php" name="mmysearchform"> <select name="posted_data[makeid]" style="width: 80%;"> <option value="" selected="selected">Select Make</option> </select><br> <form method="post" action="mmy.php" name="mmysearchform"> <select name="posted_data[modelid]" style="width: 80%;"> <option value="" selected="selected">Select Model</option> </select> <font class="CategoriesList"><a href="home.php?cat=" class="VertMenuItems"></a></font><br /> <font class="CategoriesList"><a href="home.php?cat=" class="VertMenuItems"></a></font><br /> {/capture} { include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title=$lng.lbl_mmy_search menu_content=$smarty.capture.menu cellpadding=$fc_cellpadding}
php file
Code:
$year = $_POST['year']; if ($year){ ///////////////////////////////////////////////// make query for dropdown $query = sprintf("SELECT DISTINCT makeid, makename FROM iemmy WHERE yearid='$year'"); $result = @mysql_query($query); $rowMake = mysql_fetch_array($result); ///////////////////////////////////////////////// }

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
Reply With Quote