0

I'm using Smarty, PHP and HTML. I'm giving you the URL of JS fiddle of my web page. You can see there only first question is contained within a box and all othe questions and their answers are displayed out of the box. I want to display them into the box. I tried lot of tricks but nothing worked for me. So at last I'm asking here. Can anyone help me in this regard? Thanks in advance. The smarty template code and fiddle link where you can see the plain HTML of that page are as follows: Code from Smarty file:

<table class="manage_box" cellpadding="5" cellspacing="1" style="border:1px solid #996633; font-size:13px;" width="100%" >
  <tbody>
{if $all_questions} 
  {assign var='que_seq_no' value=1}
    {foreach from=$all_questions item=qstn_ans key=key}
    <tr>
      <td align="center" colspan="2">
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
          <tr class="question_info">
            <td valign="top"><b>Question {$que_seq_no}. </b>{if $qstn_ans.question_directions}<br /><b>Direction : </b>{$qstn_ans.question_directions}{/if}<br /><b>Question : </b>{$qstn_ans.question_text}
            </td>
            <td align="right" width="5%" valign="bottom"><b>{$search_ques_id_str}{$qstn_ans.question_id}</b>
            </td>
          </tr>
      {if $test_details.is_test_questions_freez==0 && $all_questions && ($test_details.test_begin_time>$curent_server_time || $test_details.test_mode=='non-schedule') && ($test_details.is_test_lock=='0' || $test_details.is_test_lock=='')}
          <tr class="question_info">
            <td align="right" valign="bottom" colspan="2" width="100%"><a href="change_test_question.php?test_id={$test_details.test_id}&question_id={$qstn_ans.question_id}">Change Question</a>
            </td>
          </tr>
      {/if}

      {if $qstn_ans.question_file}
          <tr class="question_info">
            <td colspan="2"><img src="{$ques_thum_image_path}{$qstn_ans.question_id}_{$qstn_ans.question_file}" />
            </td>
          </tr>
      {/if}
      {if $qstn_ans.question_has_sub_ques==0}
        {if $qstn_ans.answer}
          <tr>
            <td colspan="2">Answers&nbsp;:&nbsp;</td>
          </tr>
          {foreach from=$qstn_ans.answer item=ans key=ans_no}
          <tr valign="top">
            <td valign="top" colspan="2">
            {if $ans.answer_is_right==1}{assign var='correct_ans' value=$ans_no+1}
            {/if}
            <b style="font-size:13px;">{$ans_no+1}.</b>&nbsp;&nbsp;{if $ans.answer_text!=''}{$ans.answer_text}{/if}<br />
            {if $ans.answer_file!=''}<img src="{$ans_thumb_img_path}{$ans.answer_id}_{$ans.answer_file}" />{/if}
            </td>
          </tr>
          {/foreach}
          <tr>
            <td colspan="2"><b style="font-size:13px;">Correct Answer Option : {$correct_ans}</b></td>
          </tr>
      {/if}
      {else}
        {if $qstn_ans.question_has_sub_ques==1 && $qstn_ans.sub_question}
          {foreach from=$qstn_ans.sub_question item=sub_ques_ans key=sub_ques_no}
          <tr>
            <td valign="top"><b style="font-size:13px;">Sub-question {$que_seq_no}.{$sub_ques_no+1}&nbsp;)&nbsp;&nbsp;</b>{$sub_ques_ans.question_text}
            </td>
            <td align="right" width="5%" valign="bottom"><b>{$search_ques_id_str}{$sub_ques_ans.question_id}</b>
            </td>
          </tr>
            {if $sub_ques_ans.question_file!=''}
          <tr>
            <td valign="top" colspan="2"><img src="{$ques_thum_image_path}{$sub_ques_ans.question_id}_{$sub_ques_ans.question_file}">
            </td>
          </tr>
            {/if}
            {if $sub_ques_ans.answer}
          <tr>
            <td colspan="2">Answer&nbsp;:&nbsp;</td>
          </tr>
              {foreach from=$sub_ques_ans.answer item=sub_ans key=sub_ans_no}
          <tr>
            <td valign="top" colspan="2">
                {if $sub_ans.answer_is_right==1} {assign var='correct_sub_ans' value=$sub_ans_no+1} 
                {/if}
              <b style="font-size:13px;">{$sub_ans_no+1}&nbsp;.&nbsp;</b>{if $sub_ansanswer_text!=''}{$sub_ans.answer_text}{/if}<br />
                {if $sub_ans.answer_file!=''}<img src="{$ans_thumb_img_path}{$sub_ans.answer_id}_{$sub_ans.answer_file}" >
                {/if}
            </td>
          </tr>
              {/foreach}
          <tr>
            <td colspan="2"><b style="font-size:13px;">Correct Answer Option : {$correct_sub_ans}</b>
            </td>
          </tr>
            {/if}    
          {/foreach}
        {/if}   
      {/if}
        </table>
      </td>
    </tr>
    {assign var='que_seq_no' value=$que_seq_no+1}
  {/foreach}
  {else}
    <tr>
      <td align="center" colspan="2"><b>No Test Questions Available</b></td>
    </tr>
{/if}                        
  </tbody>
</table>

{literal}
<script language="javascript" type="text/javascript">
  $('#close_details').click(function() {
     $('#transperant_popup').hide();
     $('#transperant_popup_content').hide();
     $('#transperant_popup_content').html('');
  });
</script>
{/literal}

JSFiddle link

4

1 回答 1

0

从 JsFiddls 我可以说您需要删除在第一个问题之后生成的额外标签。仅由于该标签,第一个问题是在盒子旁边显示,而其他问题则不是。要在 smarty 模板中操作,检查获取所有问题的 PHP 代码,可能标签应该来自数据库本身。除此之外,不应有此类行为的原因。

于 2013-07-18T05:17:39.717 回答