Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Display results of query


chrisjw1975

Recommended Posts

I have run a query on the database and i'm not sure how to display the results, any help would be great.

 

the query i have run is below

 

tep_db_query("select p.products_id, p.products_quantity as stock, if (p.product_wanted > p.products_quantity, p.product_wanted - p.products_quantity,
0) as stock_needed, if (p.product_wanted > p.products_quantity, p.product_buy_price, 0) as buy_price, pd.products_name from " . TABLE_PRODUCTS . " p, " . 
TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");

Link to comment
Share on other sites

So look at your post what you requested. If you would have said that you want to display the results of your query on your site, I wouldn't have given such an answer.

 

But besides, to display the results, create a table in the file you want them to be displayed and refer to the fields as they are declared in the statement.

Link to comment
Share on other sites

So look at your post what you requested. If you would have said that you want to display the results of your query on your site, I wouldn't have given such an answer.

 

But besides, to display the results, create a table in the file you want them to be displayed and refer to the fields as they are declared in the statement.

 

Sorry i'm not great with php and i was not meaning to be vague in my question, i have tried this

 

<tr>
         <td align="right"><?php echo $stock_needed; ?></td>
         <td align="right"><?php echo $buy_price; ?></td>
       </tr>

 

but nothing seems to come up (i have item that should appear)

Link to comment
Share on other sites

I have adjusted the code and added global variables but i still can't get anything to show up :(

 

<td class="main"><?php $buylist = tep_db_query("select p.products_id, p.products_quantity as stock, if (p.product_wanted > p.products_quantity, 
p.product_wanted - p.products_quantity, 0) as stock_needed, if (p.product_wanted > p.products_quantity, p.product_buy_price, 0) as buy_price, 
pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . 
(int)$languages_id . "'");?>
	<tr>
         <td align="right"><?php echo $buylist[stock_needed]; ?></td>
         <td align="right"><?php echo $buylist[buy_price]; ?></td>
       </tr></td>

 

Sorry to be a pain!!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...