Hi, I have 2 tables both with a country field in. I am doing a query on the first table to pull out all the results and then i want to do another query on table 2 which checks each result to see if the country field matches any on the loop of table 1. function selects($select) { $this->result = mysql_query($select,$this->connection); $this->row = mysql_fetch_assoc($select); } function getRes() { while ($res = mysql_fetch_array($this->result)) { $this->reser[] = $res; } return $this->reser; } //Latest 5 load results $current = new database; $current->selects("SELECT * FROM loads ORDER BY collect_date"); $cresults = $current->getRes(); // assign your db results to the template $smarty->assign('cresults', $cresults); //match results $match = new database; $match->selects("SELECT * FROM vehicles WHERE region = '$cresults[region]'"); $matches = $match->getRes(); $countrows = $match->countrows(); //Countrows $smarty->assign('countrows', $countrows); Code (markup): HTML Side {foreach from=$cresults item=cresult name=cresults} {$cresult.to_city} - Matched Results {$countrows} {/foreach} Code (markup): But {$countrows} shows 0 on all the rows, but some of them have 2, 3 matchs. Any ideas? Cheers, Adam
If you have the database schema it will be easier, I can't follow what your doing unless I read carefully.
I have attached images of what i want to do. Hopefully this will explain it better. http://www.webotal.com/1.JPG http://www.webotal.com/2.jpg http://www.webotal.com/3.JPG Cheers, Adam