Question : limit mysql insert to 22 players

Hi,

I have been given a task to create an insert page where I can add football players into a database, I am using dreamweaver with php/mysql

I am not sure how I can do this without it being long winded.


I originally thought having 22 boxes on a page with textfields, but thats crazy.


Is there a way using dreamweaver I can disable the function of inserting players for that team.


My player table is as below




1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
CREATE TABLE IF NOT EXISTS `player` (
  `player_id` int(8) NOT NULL auto_increment,
  `fname` varchar(100) NOT NULL,
  `sname` varchar(100) NOT NULL,
  `gender` varchar(10) default 'Male',
  `nationality` varchar(50) default NULL,
  `email` varchar(255) default NULL,
  `dob` date default NULL,
  `place_birth` varchar(255) default NULL,
  `height` varchar(20) default NULL,
  `weight` varchar(10) default NULL,
  `photo` varchar(255) default NULL,
  `comments` text,
  `position` varchar(255) NOT NULL,
  `team_id` int(8) NOT NULL,
  `Goals` int(5) default '0',
  `YC` int(5) default '0',
  `RC` int(5) default '0',
  `MOM` int(5) default '0',
  PRIMARY KEY  (`player_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

Answer : limit mysql insert to 22 players

>> I was thinking if the team is selected and the players selected and the total rows = 22

Yes, that would be the easiest way.  Your form inserts a single player and a recordset on the same page exists to count the total number of rows for the team_id.  So long as count(player_id) WHERE team_id = x is less than 22, display the form.  As soon as it is not less than 22, do not display the form.

>> I originally thought having 22 boxes on a page with textfields, but thats crazy.

Not as crazy as you might think...You would have the textboxes exist as an array:

<input name="player[]" type="text" />

The user fills out the form and then you would take the array and step through it, inserting each value as a new row in the mysql table.  However, this starts to get you outside of the built-in capabilities of DW unless you buy a different set of extensions.  The first solution is easier to implement but has some issues for the end user (hard to remember who has already been entered unless you take additional steps to display existing player names on the page.
Random Solutions  
 
programming4us programming4us