Jump to content

[SOLVED] Ordering PHP Arrays for a sign up website


bagpiperdude90

Recommended Posts

Ok, I have been asked by my church to write a website to allow people to sign up for childcare (especially infant and toddler nursery). I've got all my databases setup - basically, they are like this:

 

infants_0900

date (mm/dd/yy) - adult_1 - adult_2 - adult_3 - teen

 

the user id (for example, we will use 28 as the user id) is placed in the adult_1, 2, 3, or the teen cell when they sign up to work in that spot. So, as you can see, each week, there are for helpers - 3 adults, and one teen.

 

There are four of those tables, infants_0900, infants_1045, toddlers_0900, toddlers_1045 . The numbers are for the service times (9:00am and 10:45am).

 

Now, I am also hoping to later on be able to let an admin add more classes (say, a 2nd grade class, with two adults), so I want to keep each table setup the same, with the same column names, etc.

 

But, I have run into a problem. Lets say a volunteer has signed up in all four of the nursery classes, but now wants to know when and where they are working. I'm writing a page to grab the date entry in the table wherever adult_1, 2,3 or teen has their user id.

 

$q = "SELECT `date`, `teen` FROM infants_0900 WHERE teen = $userid ORDER BY date";

 

Now, I am running that query on all four tables. I could go ahead and print the results from all of them on the page. However, they would not be ordered by the date, but ordered by the table it came out of, then by the date.

 

For instance, I grab the data from infants_0900 first, then infants_1045. Lets say on 07/07/08 the user is working in infants_0900. On 06/07/08, they are working in infants_1045. Well, if I print the results from infants_0900  then infants_1045, the dates will appear as:

 

07/07/08 - Infants 9:00

06/07/08 - Infants 10:45

 

 

So, I'm thinking I need to merge all the results from the queries, then somehow sort them by the date column.

 

I cannot join all or union on MySQL, because all the table structures are exactly the same - only the table names are different.

 

Help!

 

Thanks! Let me know if I need to be more clear on something. I can also post the code, if that would help.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.