Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need to get URL into output

Author  Topic 

tomcatuk
Starting Member

6 Posts

Posted - 2009-11-25 : 14:09:12
Hi - I have a products table, and then two tables for pricing from merchants for the products, and URLs for the pages on those merchant sites. I have already got the query to find the lowest price, but I haven't figured out how to get the relevant URL from the merchant table into the display.

products_table

|vid|merchant1id|merchant2id|
|500|1234 |5678 |

merchant1_table

|merchant1id|price|url |
|1234 |80.99|http://www.....|

merchant2_table

|merchant2idD|price|url |
|5678 |79.99|http://www....|

So far, this is what I have, which just gets me the lowest price from the two merchants:

$sql1 = "SELECT price FROM merchant1 JOIN products_table ON merchant1_table.merchant1id=products_table.merchant1id WHERE CONCAT('node/', products_table.vid)='".addslashes($_GET['q'])."'";
$result1 = mysql_fetch_array(mysql_query($sql1));

$sql2 = "SELECT price FROM merchant2 JOIN products_table ON merchant2_table.merchant2id=products_table.merchant2id WHERE CONCAT('node/', products_table.vid)='".addslashes($_GET['q'])."'";
$result2 = mysql_fetch_array(mysql_query($sql2));

$node_field[0]['value'] = min($result1['price'], $result2['price']);

$display = $node_field_item['value'];

Put it another way - right now the output would be "79.99". I'd like to display that number as a hyperlink to merchant2's page for the product.

Andy Fletcher - just another blog.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-26 : 02:01:08
Post your mysql questions at www.mysql.com
This site is for MS SQL Server

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -