SalientAnimal Posted July 17, 2012 Share Posted July 17, 2012 Hi All, I have a bit of a complex question. (Well not sure how complex it is ) 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? Quote Link to comment https://forums.phpfreaks.com/topic/265832-select-option-list-from-database-table/ Share on other sites More sharing options...
SalientAnimal Posted July 17, 2012 Author Share Posted July 17, 2012 Sorry I placed this under the wrong forum, how do I move it? Quote Link to comment https://forums.phpfreaks.com/topic/265832-select-option-list-from-database-table/#findComment-1362192 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.