Explode mysql data separated by \\n


CREATE TABLE IF NOT EXISTS `survey_surveyitems` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `question` text,
  `type` enum('SingleChoice','MultipleChoice','CommentBox','SingleRow','DropDown','SetOrder','DatePicker','ImageQuestion','ImageQuestionMany','MatrixOne','MatrixMany','Rating') NOT NULL ,
  `answers` text NOT NULL ,
  `allowOwnAnswer` enum('yes','no') NOT NULL DEFAULT 'no',
  `haveToBeCommented` enum('yes','no') NOT NULL DEFAULT 'no' ,
  `commenttext` text,
  `ordervalue` int(11) NOT NULL DEFAULT '0' ,
  `survey_id` int(11) NOT NULL,
  `isRequired` enum('yes','no') NOT NULL DEFAULT 'yes',
  `tag` blob ,
  PRIMARY KEY (`id`),
  KEY `fk_okt_surveyitems_okt_ surveys1` (`survey_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=109 ;

--
-- Dumping data for table `survey_surveyitems`
--

INSERT INTO `survey_surveyitems` (`id`, `question`, `type`, `answers`, `allowOwnAnswer`, `haveToBeCommented`, `commenttext`, `ordervalue`, `survey_id`, `isRequired`, `tag`) VALUES
(3, 'What is your name', '', '', 'no', 'no', '', 2, 5, 'no', NULL),
(4, 'How old are you?', '', '> 20\
20-25\
25-30\
30-55\
55 <', 'yes', 'no', '', 1, 5, 'yes', NULL),
(5, 'Do u like the survey?', '', 'Yes!\
No\
Dunno', 'no', 'no', '', 0, 5, 'yes', NULL),

Here in I tired to explode the answers field with
for example

$q= mysql_fetch_row(mysql_qurey(“select answers from survey_surveyitems where id=5”));
$a = explode("
",$q[0]);

I cannot explode it like $a[0]…$a[2].
How can I explode this
contained mysql data?

Why didn’t you say that originally? :sick: Either way, I’m happy that you got it sorted.

Ignoring the issue of poor database normalisation, it’s because you don’t have a newline in the database. You have the characters “\” followed by “n”.

Change it to explode(’
',$q[0]); and it will work.

lol actually I tried with yours explode(’
',$q[0]); it was not working but it works for explode("
",$q[0]); but I posted here mistakenly before testing the double qoutes.
Ps. database maintains newline