Jump to content

Select Option List From database table


SalientAnimal

Recommended Posts

Hi All,

 

I have a bit of a complex question. (Well not sure how complex it is  :shrug: ) But basically here's what I want to do.

 

I want my PHP form to select the values for the drop-down from the database table. This list however needs to update real-time.

 

Here's what I mean (Hope it makes sense):

 

Every morning I get a list of stock that is available:

  • This stock is uploaded into the handset_stock table

During the coarse of the day the availablity of stock changes according to what is sold.

Each item sold gets captured seperately.

 

I want my drop-down list on my form to be populated by doing the following:

  • Count All the Stock of a particular type sold
  • Subtract the stock sold from the list of stock uploaded in the morning
  • Once the stock has sold out, this option must be removed from the list

 

At the moment I have the query below which displays on a screen what stock is available

SELECT handset_stock.handset
, handset_stock.total_stock
, COALESCE( handset_stock.total_stock - (
	SELECT COUNT( sales.phone_deals ) AS 'handset_stock'
	FROM sales
	WHERE sales.phone_deals = handset_stock.handset
	AND DATE(sys_date) = CURDATE()
	GROUP BY phone_deals ) 
, handset_stock.total_stock) AS Balance
FROM handset_stock
GROUP BY handset

 

I think what might need to happen here is that this has become a temporary table? But I'm not sure.

 

Can anyone tell me how to have my drop-down list populated by the result of this query?

 

 

Link to comment
https://forums.phpfreaks.com/topic/265832-select-option-list-from-database-table/
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.