Paste PHP Code into Heredoc for Good Choice
Hi, currently working on a page to get a form that matches my database. I want the selected "TYPE" option to be selected according to$client['CLT_type']
This is what my real code looks like (and what I tested) But I am getting this error:
Parsing error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING at 24
24 is my $ select line
if($client = $requeteClt->fetch()) {
$select = "<?php if($client['CLT_type']==2) echo 'selected'; ?>";
$page->appendContent(<<<HTML
<div id='res' height='800px'></div>
<form id='form' name='form' method='POST' action='modifierClientScript.php' style='width:100%;'>
<h2 style="text-align:center;">Modification du client {$client['CLT_libelle']}</h2>
<p>
<label for='montant'>Nom :</label>
<input type='text' value='{$client['CLT_libelle']}' name='nom' id='nom'>
<span class="error" id="nomErr"></span>
</p>
<p>
<label for='type'>Segmentation Client :</label>
<SELECT name='type' id='type'>
<optgroup label="Publics">
<OPTION value='1'>Etat
<OPTION value='2' {$select}>Collectivité
<OPTION value='3'>Entreprise publique
<optgroup label="Privés">
<OPTION value='4'>Entreprise de service
<OPTION value='5'>Entreprise industrielle
<OPTION value='6'>Autres
</SELECT>
</p><br/>
<p><br/>
<input type='button' name='submit' id='submit' value='Modifier le client'>
</p>
</form>
HTML
);
So is it possible to add PHP code to the Heredoc or do I need to manipulate my page in a different way? thank
+3
user4849541
source
to share