Author Topic: MYSQL create table on the fly with variable in PHP?  (Read 837 times)

0 Members and 1 Guest are viewing this topic.

Offline dano2000Topic starter

  • Irregular
  • Posts: 4
  • Gender: Male
    • View Profile
MYSQL create table on the fly with variable in PHP?
« on: March 01, 2010, 06:27:36 PM »
Noob here... Flames, jabs, I know I got it all coming....
I have a php/myspl db. Trying to store a meeting registration db...
I got a table for meeting and table for users.
When the user creates a new meeting they supply seats available($seats) and reserve seats available($resseats) lets say.
So where do I start when I want to create the table on the fly to store seats based off of the $seats and $resseats variables/numbers.
I know, I will have to loop to create the field names for the table on the fly.
Can I loop within a CREATE TABLE statement? Not sure what that would look like.
Or do I need to create and set of field names first, then shove them into the CREATE TABLE?
Sorta brain fried and brain blocked here.
Just kinda need a push in the right direction.
I understand the basics of php and mysql and have php putting and getting info from mysql db.
I admit though this is a little above my head.
Thanks for any info.
If it ain't broke, Don't fix it!
No mouse detected. Right-Click to continue.
It's not a bug. It's a feature.

Offline dano2000Topic starter

  • Irregular
  • Posts: 4
  • Gender: Male
    • View Profile
Re: MYSQL create table on the fly with variable in PHP?
« Reply #1 on: March 01, 2010, 06:47:09 PM »
Maybe more explanation:
I already have a table for the meeting. I want to create a table on the fly, when the meeting is entered by user, to have fields to hold the userid's of the participants that want to attend the meeting.

Sorry if I am not explaining well.

already have meeting tbl (meetingid, meetingname, maxparticipants, maxreserveparticipants, date, location ect...
already have user tbl ( userid, fname, lname, email)

what I want is to use the maxparticipants and maxreserveparticipant numbers to create a table that holds the userid's of the people who want to sign up. maxpart and maxres numbers may be different for each meeting based on user input.

participant table (meetingid, participant1, participant2 until == maxparticipants)
I want this table/s to be created when the user creates the meeting.
Hope this makes sense.
If it ain't broke, Don't fix it!
No mouse detected. Right-Click to continue.
It's not a bug. It's a feature.

Offline fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Mind Boggling!'
  • *
  • Posts: 15,443
  • Gender: Male
    • View Profile
Re: MYSQL create table on the fly with variable in PHP?
« Reply #2 on: March 04, 2010, 09:07:26 AM »
Still don't see why there can't be a single pre-existing meeting table.
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.