Jump to content

join tblproducts with tplpricing


geormanth

Recommended Posts

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;

Link to comment
Share on other sites

  • 7 months later...
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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated