0

I wanted to get reloading data, without refreshing the page. Everything works, exepect for the echo syntax. Here is the the echo syntax, maybe I am missing something:

<?php
echo "
    <h2>Abstimmungen</h2>
    <p>Hier werden die Showtime Abstimmungen gelistet.</p>
    <table>
        <thead>
            <tr>
                <td>#</td>
                <td>Titel</td>      
                <td></td>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($polls as $poll): ?>
            <tr>
                <td><?=$poll['id']?></td>
                <td><?=$poll['title']?></td>    
                <td class=\"actions\">
                    <a href=\"vote/vote.php?id=<?=$poll['id']?>\" class=\"view\" title=\"View Poll\"><i class=\"fas fa-eye fa-xs\"></i></a>
                </td>
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
    ";
?>

Thanks in advance

yFlix
  • 1
  • 1

2 Answers2

0

The problem may be that PHP is trying to evaluate your variables, and is finding unexpected characters. Here is an example:

$a = 3;
$b = "ff $a ff";
//the value of $b is "ff 3 ff";

The solution is simply to use single quotes instead of double:

$a = 3;
$b = 'ff $a ff';
//the value of $b is "ff $a ff";
luek baja
  • 1,475
  • 8
  • 20
0

Two ways to output html, one is html tag instead of php tag, other is echo function. Please use unified one, avoid error.

    <h2>Abstimmungen</h2>
    <p>Hier werden die Showtime Abstimmungen gelistet.</p>
    <table>
        <thead>
            <tr>
                <td>#</td>
                <td>Titel</td>      
                <td></td>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($polls as $poll): ?>
            <tr>
                <td><?=$poll['id']?></td>
                <td><?=$poll['title']?></td>    
                <td class="actions">
                    <a href="vote/vote.php?id=<?=$poll['id']?>" class="view" title="View Poll"><i class="fas fa-eye fa-xs"></i></a>
                </td>
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
Xingchao
  • 96
  • 4