Search code examples
phphtmlhtml-selectdropdownbox

Blank Screen When using Echo '<DIV>..</DIV>'


I am currently trying to enable a select view within the page. However, I have encountered an issue. The page will display a list of items/objects when the following PHP code is used:

<?php

echo elgg_view_title($vars['entity']->title);
echo elgg_view('output/longtext', array('value' => $vars['entity']->description));                              
echo elgg_view('output/longtext', array('value' => $vars['entity']->my_options));
echo elgg_view('output/tags', array('tags' => $vars['entity']->tags));
echo elgg_view('output/my_options', array('my_options' => $vars['entity']->my_options));

However, the page would be blank when I add in the following code ontop of the above code:

echo '<DIV> <html>
    <body>

        <select>
            <option value="A">a</option>
            <option value="B">b</option>
            <option value="C">c</option>
            <option value="D">d</option>
        </select>

    </body>
</html> </DIV>'

Therefore, the entire code would look something like this:

<?php

echo elgg_view_title($vars['entity']->title);
echo elgg_view('output/longtext', array('value' => $vars['entity']->description));                              
echo elgg_view('output/longtext', array('value' => $vars['entity']->my_options));
echo elgg_view('output/tags', array('tags' => $vars['entity']->tags));
echo elgg_view('output/my_options', array('my_options' => $vars['entity']->my_options));

echo '<DIV> <html>
    <body>

        <select>
            <option value="A">a</option>
            <option value="B">b</option>
            <option value="C">c</option>
            <option value="D">d</option>
        </select>

    </body>
</html> </DIV>'

Can anyone, pls help and point out what's seems to be wrong? Thank you


Solution

  • You are missing a ; at the end of the echo statement.

    Replace

    echo '<DIV> 
    <html> 
    <body> 
    <select> 
    <option value="A">a</option> 
    <option value="B">b</option> 
    <option value="C">c</option> 
    <option value="D">d</option> 
    </select> 
    </body> 
    </html> 
    </DIV>'
    

    with

    echo '<div> 
    <select> 
    <option value="A">a</option> 
    <option value="B">b</option> 
    <option value="C">c</option> 
    <option value="D">d</option> 
    </select>
    </div>';
    

    as it is not the correct structure of HTML