Hi, I've three tables in my database namely user, preferences and questions. My preferences table is like this..
CREATE TABLE IF NOT EXISTS `preferences` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`questionid` int(11) DEFAULT NULL,
`answers` varchar(100) DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `questionid` (`questionid`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
My questions table is like this
CREATE TABLE IF NOT EXISTS `questions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`question` varchar(400) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
I given foreign keys to preferences table to questionid from questions table id and user_id from user table id. Now i'm inserting answers values into preferences. Can i know how to fetch questionid and user_id into preferences table. My questions are in _form.php file.
CREATE TABLE IF NOT EXISTS `preferences` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`questionid` int(11) DEFAULT NULL,
`answers` varchar(100) DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `questionid` (`questionid`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
My questions table is like this
CREATE TABLE IF NOT EXISTS `questions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`question` varchar(400) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
I given foreign keys to preferences table to questionid from questions table id and user_id from user table id. Now i'm inserting answers values into preferences. Can i know how to fetch questionid and user_id into preferences table. My questions are in _form.php file.
-
PreferencesController.php (4.18K)
: 2 -
_form.php (3.17K)
: 2