Q:

Getting an syntax error, unexpected T_STRING in select option in html,php

Hi i have small project which will give you news from past 4,6,10 weeks by using select option in html. I am getting an syntax error, unexpected T_STRING in select option tag. I understand the error as i cant use php inside open php tag. But i dont know how can i solve this error. Any help.Thanks.
Here is my code:
<?php
$page['doctype'] = true;
$param = array_merge($_GET, $_POST);

$return = array();
if($param['aktion'] == 'edit-news')
{
    $page['register-edit-news'] = array(
    1   => array( 'Edit-News','aktiv',$page['script'],'',''),
);

if(isset($_POST['BtnSubmit']))
   {

      if(($_POST['news'])==4){

      $sql=" SELECT DISTINCT ad_news_texte.headline, ad_news.datum_archiv
FROM ad_news_texte
INNER JOIN ad_news_oe ON ad_news_texte.news_id = ad_news_oe.id_ad_news
INNER JOIN ad_news ON ad_news_oe.id_ad_news = ad_news.id
WHERE ad_news.datum_archiv
BETWEEN curdate( ) - INTERVAL DAYOFWEEK( curdate( ) ) +28
DAY AND curdate( )
";

$sql_select=mysql_query($sql);
while($row = mysql_fetch_array($sql_select)) {
  echo $row['headline'] . " " .$row['datum_archiv'] ;
  echo "<br>";
}
}

if(($_POST['news'])==10){

      $sql=" SELECT DISTINCT ad_news_texte.headline, ad_news.datum_archiv
FROM ad_news_texte
INNER JOIN ad_news_oe ON ad_news_texte.news_id = ad_news_oe.id_ad_news
INNER JOIN ad_news ON ad_news_oe.id_ad_news = ad_news.id
WHERE ad_news.datum_archiv
BETWEEN curdate( ) - INTERVAL DAYOFWEEK( curdate( ) ) +70
DAY AND curdate( )
";

$sql_select=mysql_query($sql);
while($row = mysql_fetch_array($sql_select)) {
  echo $row['headline'] . " " .$row['datum_archiv'] ;
  echo "<br>";
}
}

$html =     
'
<body bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>
<td class="welcome-page-hint">

<table width="538" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>

<h3>News</h3>

<form name="UserInformationForm" method="POST" action="#">

      <select name="news">
         <option value="4" <?php if($_POST['news']=="4") echo "selected=selected"; ?>>Show news from the last 4 weeks</option>
         <option value="6" <?php if($_POST['news']=="6") echo "selected=selected"; ?>>Show news from the last 6 weeks</option>

      </select>
      <br/><br/>
      <input name="BtnSubmit" type="submit" value="Submit">
</form>

</td>
</tr>
</table>

</td>
</tr>

</table>';
$return = array(
        'status' => 1,
        'html'  => $html
    );

    echo(json_encode($return)) ;
}
?>

A:

You can't have php code inside a variable in php code. 
What you should do is to escape the string and then concatenate.
<option value="4" '. (($_POST['news']=="4") ? "selected=selected" : "") .'>Show news from the last 4 weeks</option>
<option value="6" '. (($_POST['news']=="6") ? "selected=selected" : "") .'>Show news from the last 6 weeks</option>

Instead of trying to put a new php code block in there I have just escaped the string, used ternary operator and then concatenated the 3 parts. 

