Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • 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.