Mustafa Azad Mustafa Azad - 3 months ago 28
PHP Question

Embedding html into PHP

I have the below code

$Query='SELECT * FROM `courses`';
echo'<select name="courses" multiple>';
{ echo"<option value=\"";$data['title'];echo"\">";$data['title'];echo'</option>';}

I am trying to return values from a table,Database into a Multiple Selection menu. but it keeps giving me the below error

Parse error: syntax error, unexpected 'echo' (T_ECHO) in C:\wamp\www\ETT Logo\Controlpanel\addteacher.php on line 51

Please note that Line 51 is the line inside of the 'while' brackets.

Will Appreciate any solutions.


Your problem is you can not make echo option in right way. Try below code it's works for you

$Query='SELECT * FROM  `courses`';
echo'<select name="courses" multiple>';
     echo "<option value='".$data['title']."'>".$data['title']."</option>";