且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用php和mysql基于循环计数器在循环中运行多选语句

更新时间:2022-10-27 22:46:15

last_Date





例如,如果当前product_id为1,则获取price_id = 1且date =


last_Date
的价格表中最后一条记录的日期
 2)从与当前产品相关的价格表中获取最后价格





例如如果当前产品id为1,则获取price_id = 1且date = 的价格表中最后一条记录的价格ckquote>

last_Date



 3)在最近2条记录的场地价格之间取得差异





例如,如果当前产品ID为1,则在product_id = 1和date =

的价格表中的最后一条记录2记录的字段价格之间有所不同

i work with PHP And MySQL

I have two table :

Products (product_id,product_name)

Prices (product_id,price_id,price,date)

Any product have unlimited price

Type of "date" field in table "Prices" is datetime (like 2014-02-23 18:41:22) – when I saving any record current datetime saved in this field (last record can be determine with this field) .

I want a loop for all products that can do below actions for any product :

1)get Last date from prices table that related with current product and set it to $last_Date



for example if current product_id is 1 get date of last record in price table that product_id=1 and date=$last_Date

2)get Last price from prices table that related with current product



for example if current product id is 1 get price of last record in price table that product_id=1 and date=$last_Date

3)get different between field price from last 2 record



for example if current product id is 1 get different between field price of last record 2 record in price table that product_id=1 and date=$last_Date

4)get min and max *price* field value that product_id=1 and date=$last_Date

last_Date



for example if current product_id is 1 get date of last record in price table that product_id=1 and date=


last_Date
2)get Last price from prices table that related with current product



for example if current product id is 1 get price of last record in price table that product_id=1 and date=


last_Date

3)get different between field price from last 2 record



for example if current product id is 1 get different between field price of last record 2 record in price table that product_id=1 and date=