The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× 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
#21
I guess if I dont want to offer dodgeball on a Sunday, I would not add that code to that day Smile
That is how I would do it anyway...but that's more because I have no idea what I'm doing.
  Reply
#22
haha. That's exactly the answer I would have given. That's fine. I'm about to start doing a video series on building a userspice project from beginning to end. I'll show how to be more dynamic there. Gimme a sec.
  Reply
#23
This is the whole thing with the functions. The only thing I changed was adding a times array to set the times and I had to reformat the table. The functions are the same

https://pastebin.com/UzSFN00N
  Reply
#24
That doesn't seem to work. It is saying that there are 6 spots available on each day (while that is not the case...looking at the old code on a different page).
  Reply
#25
Ahh. Because we're getting the days of the week differently.

Under global $db; add the line
$day = strtolower($day);

Since the array of days are capital and the database uses lowercase, it was throwing it off.
  Reply
#26
oww...ofcourse! Duh! Silly me. Sorry
Mudmin Sad
  Reply
#27
It's not your fault. I wrote it Smile
  Reply
#28
So, if I wanted to have this function to also check the time in the database...that would be something like this? :

$count = $db->query("SELECT day FROM users WHERE day = ? AND time = ?",array($day).($time))->count();

That would make it more dynamic right? So I could have yoga at 10:00 and dodgeball at 15:00 on a Friday.
  Reply
#29
Not really because that would require too much in your users table to work. If I were trying to do it simply in one table, I would do a table called events with one line per event and the columns
id
event
monday_time
monday_spaces
tuesday_time
tuesday_spaces
etc

That's not the most dynamic way of doing it, but it's the simplest to comprehend.

Then when you add dodgeball, you add the event, and the time/spaces for each day.

Then signups would go in another table called signups
id
event_id
user_id
day

Then you cross reference the two tables.
  Reply
#30
That's where the user_id comes from. When a user signs up, their id gets inserted into the signups table, so if
yoga is event 1
dodgeball is event 2

my signup would look like
id = whatever(doesn't matter)
event_id=2(dodgeball)
user_id=17(my id in the users table)
day = wednesday

Basically that signup table ties the users table (user_id) together with the events table (event_id) and adds the day that I want to sign up for. All of a sudden we have these 3 tables that work together without caring how many rows the other has. You can have unlimited users, unlimited events and unlimited signups and because the ids "relate" the info from one table to another, it's infinately dynamic.

My adding to the users table you have to keep creating my more events and more times and more everything until it gets out of control.

There are ways to make it more dynamic (more than one yoga per day etc), but like I said, this is how that works at its core.

You'll notice we do the same thing in userspice.
The pages table is an id for each page.
The permissions table is an id for each permission level
page_permission_matches determines which permission level can visit which page.
  Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)