Thanks Kyle; I have had enough tonight as I have been over 5 hours trying to sort this out!
What is the overall task you are trying to perform?
You are correct and this code is validating some form input and the code I had so far was:
if (!empty($_REQUEST['performer_A1'])) {
if ( in_array( $_REQUEST['performer_A1'], $result_per) ) {
$artist_A1 = $_REQUEST['performer_A1']; }
else{ $errors[] = 'There is a problem with artist A1';
}
}
else {$errors[] = 'You forgot to enter an artist A1.';}
The final code should:
Recive the name from the form
Check to make sure there is a name
Check the name is in the database
If the name is not in the database put it there - will need to get the ID for the next part
Link the name to the record
I have a table with performer and performer_ID I also have a table with the record details.
There will be multiple records from the one performer and so to save space I am putting the ID into the record table and not the name.
I hope this has not confused you to much!
--
-- Table structure for table `performer`
--
CREATE TABLE IF NOT EXISTS `performer` (
`per_ID` smallint(4) NOT NULL AUTO_INCREMENT,
`full_name` varchar(50) NOT NULL DEFAULT 'Name',
PRIMARY KEY (`per_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='List of performers' AUTO_INCREMENT=9 ;
--
-- Dumping data for table `performer`
--
INSERT INTO `performer` (`per_ID`, `full_name`) VALUES
(1, 'Luciano Pavarotti '),
(2, 'Enrico Caruso'),
(3, 'Jose Carreras '),
(4, 'Placido Domingo'),
(5, 'Maria Callas'),
(6, 'Joan Sutherland'),
(7, 'Kiri Te Kanawa'),
(8, 'Anna Netrebko');
--
-- Table structure for table `association`
--
CREATE TABLE IF NOT EXISTS `association` (
`ass_ID` smallint(5) NOT NULL AUTO_INCREMENT COMMENT 'Identifier',
`number` varchar(50) NOT NULL DEFAULT 'number',
`company` smallint(4) NOT NULL,
`performer_1` smallint(4) NOT NULL,
`performer_2` smallint(4) NOT NULL,
`title` varchar(60) NOT NULL DEFAULT 'Unknown',
`speed_1` tinyint(2) NOT NULL,
`speed_2` tinyint(2) NOT NULL,
PRIMARY KEY (`ass_ID`),
UNIQUE KEY `number` (`number`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Associations with performer and record company' AUTO_INCREMENT=2 ;
--
-- Dumping data for table `association`
--
INSERT INTO `association` (`ass_ID`, `number`, `company`, `performer_1`, `performer_2`, `title`, `speed_1`, `speed_2`) VALUES
(1, '1234', 1, 1, 2, 'La Traviata', 78, 75);