Adding a Watch Wearing Log to This Site
Everyone knows I'm a watch geek, but I've now taken it one step further and added a watch wearing log to this site.
Ok, so what am I talking about here? Well, you know how Iโm a watch nerd, and have my collection listed on this site? Well, I decided to build upon this by adding a random watch picker, and watch wearing log too.
Pretty simple, right? But building this whole thing proved to be far more difficult than I first thought. Hereโs the steps involved in making this work:
- Take my watch collection and exclude and watches in the โSoldโ section
- Of those watches, pick a random one
- Display that random watch on the
random-watch
page - Check if the person visiting the pages is logged in (I.E. me)
- If they are, display a button that allows me to โwear this watchโ
- If theyโre not, hide the โwear this watchโ button
- Include a button to โtry againโ if the random watch isnโt appropriate (for example if Iโm working in the garden that day and it chooses a dress watch)
- When I click the โwear this watchโ button, write the watch name and the date I wore the watch to a text file
- Parse that text file and display the date and watch name under the log section
- Make sure the watch name links back to the appropriate watch within my collection
See, thereโs lots going on here, right? But Iโve managed to come up with a way to get it all working as it should. Thank goodness for PHP!
All in all the snippet of code that does this is a little over 100 lines. This is probably small fry for many of you developers out there, but Iโm not a dev, so Iโm very proud of myself for working this out. Yay me!