|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
ssur.linux@gmail.com Smarty n00b
Joined: 23 Jul 2015 Posts: 2
|
Posted: Fri Jul 24, 2015 8:59 am Post subject: I want to display a multiple choice questionnaire |
|
|
The data is like this :-
<?php
$questions = Array ( [1] => Array (
"q_id" => 1,
"q_desc" => 'Question-1?',
"q_mcq_type" => 'radio',
"answers" => Array (
[0] => 'choice-1',
[1] => 'choice-2'
)
),
[2] => Array (
"q_id" => 2,
"q_desc" => 'Question-2?',
"q_mcq_type" => 'checkbox',
"answers" => Array (
[0] => 'option-1',
[1] => 'option-2'
)
)
);
<!--Initiation of Smarty Class & Assign to a Smarty Variable "questions"-->
?>
I want to show like :-
1. Question-1?
choice-1
choice-2
2. Question-2?
option-1
option-2
My question is what would be the tpl file?
I tried the following (It is incomplete)
<html>
<head>
<title> Multiple Choice Questions </title>
</head>
<body>
{foreach item="question" from=$questions}
<div>
{$question['q_id']}.{$question['q_desc']}
<div><!--How to Show $question['answers'] --></div>
</div>
{/foreach}
</body>
</html>
Thanks in advance. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
Back to top |
|
ssur.linux@gmail.com Smarty n00b
Joined: 23 Jul 2015 Posts: 2
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|