Jump to content


Photo

hard to title! about numbers of objects and MySQL


  • Please log in to reply
5 replies to this topic

#1 black.horizons

black.horizons
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 13 September 2006 - 11:51 AM

Hi there,

Basically my idea was to have a file with variables names i.e. $team_number [where the value is from 1 upto an unknown number - probably no more than 30], and for each number have a MySQL table. I was thinking at the start of initially having the 30 tables, with 30 scripts - one script/page per table. However they all run off the same format...

        $date = $contact -> date;
$arrange = $contact -> arrange;
$notes = $contact -> notes;
        $member1 = $contact -> member1;
        $member2 = $contact -> member2;
        $member3 = $contact -> member3;
        $member4 = $contact -> member4;
        $member5 = $contact -> member5;
        $member6 = $contact -> member6;
        $member7 = $contact -> member7;
        $member8 = $contact -> member8;
        $member9 = $contact -> member9;
        $member10 = $contact -> member10;
        $member11 = $contact -> member11;
        $member12 = $contact -> member12;
        $member13 = $contact -> member13;
        $member14 = $contact -> member14;
        $member15 = $contact -> member15;
        $member16 = $contact -> member16;
        $member17 = $contact -> member17;
        $member18 = $contact -> member18;
        $member19 = $contact -> member19;
        $member20 = $contact -> member20;
        $member21 = $contact -> member21;
        $member22 = $contact -> member22;

Every "$member" field just holds the name of a member of the team - basically for management to know how is working on which team.

Is there a way to make one template file instead of 30 files - one per table, which can write to any of the 30 tables, depend on which link was clicked to get there if you know what i mean.

Also at the minute, with the rest of the script I have, I keep all my database connections in a seperate database.php file, and call each of them by calling a function through a form.

Can anybody even tell me whether this is a good idea or not!?!

TIA, Alex

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 13 September 2006 - 12:00 PM

Sounds like a very bad idea!

I can't see exactly what you're trying to do here, but your database design is key... You could probably do what you're after with two or three tables and save yourself a hell of a lot of coding.

Table 1 (members) - unique_id, member_name, team_id
Table 2 (teams) - unique_id, team_name


You can link the member.team_id to the teams.unique_id to receive the info you needed.

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 black.horizons

black.horizons
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 13 September 2006 - 12:08 PM

yeah, actuallly upon reflection I can see that I could have one MASSIVE table, with the 30 teams worth of data entered in, but basically there is a manager for every team, and they can only see their one team page for editing, so i'd need to have a fiddle around with it.

To tell you the truth I should hang my head in shame..i have no DB design...at all! To the drawing board!

#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 13 September 2006 - 12:33 PM

OK, don't worry,

How about something like this.

Table 1 (members) - unique_id, member_name, team_id, manager_id
Table 2 (teams) - unique_id, team_name, manager_id


This will allow you to do everything you need.  Do you want a few examples?

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#5 black.horizons

black.horizons
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 13 September 2006 - 12:42 PM

i think i have it sorted...but I don't need to store any information about the members, just the team lists, and their managers.

I'll have to think more about it, but when I do get it sorted i'll leave a note! Cheers Huggie!

#6 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 13 September 2006 - 12:47 PM

The above table structure would allow for that and you wouldn't need to save any details about them.

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users