Featured Item on home page
In my last post, I was able to ask about and create an automated query that updates the content of the div to the latest updated product.
Having done that, I'm having some trouble with the logic for this idea:
In the left div on the home page, where there is a featured product, I'd like to add an option to the Product_Update.php and Product_Insert.php pages to make this a featured item.
My Progress So Far:
----------------------
I have added a TinyInt column to my db with a default value of '0'. I called it ProductFeature.
I created the checkbox element in the form above the Available Online question. I then adjusted the update server behaviours. The code I used is:
<label for="ProductFeature" class="readonly-checkbox">Featured Product?</label>
<input <?php if (!(strcmp(((isset($_POST["ProductFeature"]))?$_POST["ProductFeature"]:""),1))) {echo "checked=\"checked\"";} ?> name="ProductFeature" type="checkbox" id="ProductFeature" value="1" /> (check to make this item a Feature on the home page)
The db is being updated properly with a value of 1 or 0.
Now, here's my difficulty: How do I apply the following logic?
"There is only one row that is allowed to be a Featured Product (ProductFeature=1). When I make a new product a featured-product, the previous featured-product must change its ProductFeature value from 1 to 0; then the new featured-product information (retaining the ProductFeature=1 value) will be called to the div on the home page."
Thanks,
Pete