Reputation: 171
Is it possible to put PHP-code surrounded by HTML which is surrounded by PHP? Here is a little code-snippet. All of that is in PHP-brackets. The browser displays the table but not the PHP values.
echo "<tr>";
echo '<td class="tg-031e"><?php echo $Auftragsnummer;?></td>';
echo '<td class="tg-031e"><?php echo $Modellbezeichnung;?></td>';
echo '<td class="tg-031e"><?php echo $Untersuchungsart;?></td>';
echo '<td class="tg-031e"><?php echo $TUEV_Stelle;?></td>';
echo '<td class="tg-031e"><?php echo $TUEV_Termin;?></td>';
echo "</tr>";
Regards Bluefox
Upvotes: 0
Views: 89
Reputation: 1866
Concatenation
echo '<td class="tg-031e">' . $Auftragsnummer . '</td>';
But if you have a lot of HTML it's better to close your php tag
<?php your code ?>
<tr>
<td class="yourClass"> <?php echo $yourVar; ?> </td>
<tr>
Upvotes: 6
Reputation: 675
Using sprintf()
.
<?php
echo sprintf('<td class="tg-031e">%s</td>', $Auftragsnummer);
Or, as a loop/array construct:
foreach(array(
$Auftragsnummer,
$Modellbezeichnung,
$Untersuchungsart,
$TUEV_Stelle,
$TUEV_Termin) as $item) {
echo sprintf('<td class="tg-031e">%s</td>', $item);
}
Upvotes: 0
Reputation: 622
You can go for HEREDOC :
$html = <<<HTML
<tr>
<td class="tg-031e">{$Auftragsnummer}</td>
<td class="tg-031e">{$Modellbezeichnung}</td>
<td class="tg-031e">{$Untersuchungsart}</td>
<td class="tg-031e">{$TUEV_Stelle}</td>
<td class="tg-031e">{$TUEV_Termin}</td>
</tr>
HTML
;
echo $html;
Upvotes: 1
Reputation: 151
you do not need to close the php bracket do more like this
echo '<td class="tg-031e">' .$Auftragsnummer. '</td>';
Upvotes: 1
Reputation: 9001
You can put a string in an echo
command like so:
$string = 'hello world';
echo 'I wanted to say '.$string.'!'; //outputs "I wanted to say hello world!"
so your code should look like:
echo '<tr>';
echo '<td class="tg-031e">'.$Auftragsnummer.'</td>';
echo '<td class="tg-031e">'.$Modellbezeichnung.'</td>';
echo '<td class="tg-031e">'.$Untersuchungsart.'</td>';
echo '<td class="tg-031e">'.$TUEV_Stelle.'</td>';
echo '<td class="tg-031e">'.$TUEV_Termin'.</td>';
echo '</tr>';
Upvotes: 1
Reputation: 3236
echo is PHP. So you should just do something like this :
echo '<td class="tg-031e">'.$Auftragsnummer.'</td>';
Upvotes: 0