View Single Post
  #8  
Old 12-18-2008, 09:16 AM
  Vetrivel's Avatar 
Vetrivel Vetrivel is offline
 

eXpert
  
Join Date: Apr 2008
Posts: 398
 

Default Re: Data passing between template and PHP file

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:
Originally Posted by AMMoyer
After implementing some of the suggestions and a couple of easy things I found this is what is happening.

php file
Code:
<?php $year = $_POST['year2']; ///////////////////////////////////////////////// make query for dropdown $query = sprintf("SELECT DISTINCT makeid, makename FROM iemmy WHERE yearid='$year'"); $result = @mysql_query($query); $rowMake = mysql_fetch_array($result); ///////////////////////////////////////////////// if (mysql_num_rows ($result) >= 1) { $makeid = array(); while ($rows = mysql_fetch_array ($result, MYSQL_ASSOC)) array_push ($makeid, $rows); $smarty->assign ("makeid", $makeid); } ?>

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