× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Retrieving data from database
Hello Smile

I am (still) not very well versed in php at all, but I fiddle with it anyway. I'll try to explain what I want to do.

I added a column to the users table named day. Every user has a day of the week in their profiles which is stored in that column.

Now I would like to show on a public page (in a sort of calendar) the number of people who have Monday or Tuesday, etc.
So if there are 5 users with Monday in their profile, I would like to show the number 5 on that calendar page (preferably on Monday).
If there are 2 people who have Wednesday in their profile, it shows 2 on the calendar page.

I'm sure something like that should be possible, but I cannot seem to get it right in UserSpice.

I think it probably should look like this more or less: $query = $db->query("SELECT * FROM users WHERE day = monday",array($day));
But then I don't know how to show/echo the results Sad

Can anyone please give me a hand with this?
Will all 7 days be on at once? Or are you just trying to show the current day? do you have a little bit of HTML that shows the type of calendar you want to do? Having that would help me give you both an answer and showhow I did it
Hello mudmin, thank you for your quick reply.

I was hoping to use the event calendar from Jamezs ( https://userspice.com/forums/showthread....t+calendar ) as that is the only UserSpice event calendar that I could find really. But it doesn't seem like he ever continued that project unfortunately.

A real calendar would of course be preferable (as it just looks better) but It does not have to be a real calendar per se.
It could also just be a page where all the days are listed.
Something like this:

Monday: 5
Tuesday: 1
Wednesday: 2
Thursday: 0
Friday: 6
Saturday: 0
Sunday: 6

Even better would be to show the reverse of that.
There are 6 spots available on any given day, so if it could show the number of spots left that would be cool.

So Monday: 1 (as there are 5 users with Monday in their profile), Tuesday: 5, etc.
Ok. Give me a second. Are users "signing up" for a day? Like would you want a user to be able to change their day from this page?
Signing up (or off) for a day would be something that i would love to have yes.

But for now I was just thinking I would add all that manually (as the admin) to their profiles and have the results show on some public page so people could see how many spots were left (even if they are not a user or are not logged in)
Ok. And you have the days stored in a column called day and the day is in lowercase letters like monday not Monday right?
ehm...yes. I suppose I could just always enter it in small letters Smile
(01-04-2019, 09:39 AM)LBC Wrote: ehm...yes. I suppose I could just always enter it in snall letters Smile

Nope that's fine.
Ok. You should be able to paste the code from this in the middle of any userspice page and it should work.

Ooh! That is amazing! Thank you so much mudmin.
This really gives me something to work with now.

How would I go about it to get it like this:

Monday: 4
Tuesday: 6
Wednesday: ..
Thursday: ..
Friday: ..
Saturday: ..
Sunday: ..

Is there a line of code that i can just paste anywhere?

Forum Jump:

Users browsing this thread: 1 Guest(s)