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!
Want more?
So you've read this post and you're still not satisfied? Ok then, here's some other stuff for you to do: