Random sticky notes ideas


Hello and i hope that you are having a splendid day,

i could use some wisdom from experienced programmers. As much as i’d like to be as useful as Donald Knuth with calculus solutions, complex concepts are sometimes beyond me or i am just not able to see a solution at the time.

my problem: i am making sticky notes (unordered list made to look like the colored paper notepads with adhesive strips that are often called sticky notes.) I only have two at the moment but there could be over twenty in the future. I want to create two random values: color and angle, which are related to css selectors.

last night i came up with a quick and dirty solution to test two sticky notes but this method of mine is, well, awful. I’d like some ideas about how to accomplish this task with unknown amount of stickies AND how should i create notes that are not hard-coded?

my current amateurish code for two stickies:

$temp1 = mt_rand(1,4); $temp1x = mt_rand(1,4); $temp2 = mt_rand(0,1);
while ($temp1 === $temp1x) { $temp1x = mt_rand(1,4); }

<li class="stickynote color<?php echo $temp1; ?> angle<?php echo $temp2; ?>">
<li class="stickynote color<?php echo $temp1x; ?> angle<?php if ($temp2) { echo '0'; } else { echo '1'; } ?>">

so css is obviously: li.stickynote and li.color1 and li.angle0
i’d like to keep the angles opposite each other for every pair in the ul. so angles of even numbers must be opposite of odd numbers. Colors must also be different for even numbers. I only use two angles: transform: rotate(3deg); and transform: rotate(-3deg);

also, these notes are hardcoded but i’d like to have php handle this for me from some source. what is the best approach here: database, flatfile or what?

I hope that i make sense.
Thank you for your time.

1 Like

yes, Thank you. I forgot about GitHub. I need to setup an account.

Great tip, @astonecipher. :slight_smile:


The tip wasn’t to get one, it was showing what is already available

1 Like

i am an idiot! lol.
i thought that you were telling me to post at github for ideas.
my apologies. i get the dunce cap today.