geormanth Posted October 5, 2010 Share Posted October 5, 2010 Hi, I tried to joint tblproducts with pricing with no results So far I have $result = select_query ('tblproducts', '', array ('hidden' => ''), 'order', 'ASC', '0,30'); while ($data = mysql_fetch_array ($result)) { $id = $data["id"]; $type = $data["type"]; $gid = $data["gid"]; $name = $data["name"]; $products[] = array ( 'id' => $id, 'type' => $type, 'gid' => $gid, 'name' => $name ); } $smartyvalues['products'] = $products; How to take tblpricing.month from tblpricing. I make a query SELECT * FROM `tblproducts`, `tblpricing` WHERE tblpricing.type='product' AND tblproducts.id=tblpricing.relid working in phpmyadmin how to insert $smartyvalues['products'] = $products; 0 Quote Link to comment Share on other sites More sharing options...
disgruntled Posted May 21, 2011 Share Posted May 21, 2011 Hi, I tried to joint tblproducts with pricing with no results So far I have $result = select_query ('tblproducts', '', array ('hidden' => ''), 'order', 'ASC', '0,30'); while ($data = mysql_fetch_array ($result)) { $id = $data["id"]; $type = $data["type"]; $gid = $data["gid"]; $name = $data["name"]; $products[] = array ( 'id' => $id, 'type' => $type, 'gid' => $gid, 'name' => $name ); } $smartyvalues['products'] = $products; How to take tblpricing.month from tblpricing. I make a query SELECT * FROM `tblproducts`, `tblpricing` WHERE tblpricing.type='product' AND tblproducts.id=tblpricing.relid working in phpmyadmin how to insert $smartyvalues['products'] = $products; the query would bring you a double data set you want to return it as one table. php version you need to populate $product_id $sql = "SELECT DISTINCT * FROM tblproducts product JOIN tblpricing price ON product.id = price.relid WHERE price.type='product' AND product.id = '" . $product_id . "'"; $query = mysql_query($sql); // use this line if you want an array otherwise omit this $product = Array(); // associative array fetching (assoc) while($fetch = mysql_fetch_assoc($query){ $product = $fetch; } // for single data entry $smartyvalues['product'] = $product; // OR for an array $smarty->assign('productArray', $product); // for a single item using smartyvalues just use {$product} in the tpl file // In the tpl file you will access the data associatively with {$product[0].column_name} // EG: {$product[0].id} will return the product id of the first array item Hope this helps somebody out 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.