In the table “ogitems”, I have a column called “itemname”, “month”, and “price”.
There duplicate items, arranged by month.
I want to check “itemname” to see if any rows have the same value for itemname, and if yes, echo the “itemname” along with the last two months and the pricing for these two months.
EXAMPLE:
“itemname” = CHEESE CHEDDAR
CHEESE CHEDDAR is found in months 11 AND 12 (so there is two records/rows for CHEESE CHEDDAR). 11 has “price” of 51 while 12 has “price” of 54
I want to echo that information into an anchor tag…
<a href="pricetrend.php?date=<?php echo "" . $row['month'] . "" ?>&price1=<?php echo $price1; ?>&price2=<?php echo $price2; ?>&item=<?php echo "" . $row['itemname'] . ""?>;">
Basically, I am trying to grab the two most recent prices for one item and echo them into this anchor tag. Thanks in advance for any help!
I am assuming that your month is a
date field, this should workSQL Fiddle link: http://sqlfiddle.com/#!2/d63a0/4