close ad
Help us test the new Databridge BETA with MySQLi support
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Featured Item on home page

Thread began 11/21/2009 2:17 pm by pete268226 | Last modified 11/24/2009 8:47 pm by Eric Mittman | 856 views | 3 replies |

pete268226

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

Sign in to reply to this post

Eric Mittman

The scenario that you posted about here is a little complex and will require a good deal of custom coding to account for. Essentially you will need to check to see if the item you are adding or updating is set to be featured. If it is then you will need to update all of the items and set the featured to 0 before you insert or update the current record. Then when you insert or update the current record no others will be set to be featured expect the one you are currently working with.

Sign in to reply to this post

pete268226

I agree - possibly too complex for my skillset at this point. I have a better idea - I'm going to create an Admin page that my client can fill out and I'll put the info in that left-side div. Probably a better solution in the long run!

Thanks,
Pete

Sign in to reply to this post

Eric Mittman

That sounds like a reasonable solution for getting some extra info on the home page. If you are wanting to go with the other solution and need some pointers or have questions let us know.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...