-1

im having difficulties calling php function in my html table.

    <table>
        <thead class="table">
        <tr><th>Letter</th><th>Sender</th></tr>
        </thead>
        <tbody>
        <?php require_once 'assets/userFunctions.php';
        foreach ($myCvs as $cv){
            echo "<tr>
            <td>{$cv['cv']}</td>
            <td>getUsernameById({$cv['senderid']})</td>
            </tr>";
        }
        ?>
        </tbody>
    </table>

And in the table i just see getUsernameById(2) for example...

LF00
  • 27,015
  • 29
  • 156
  • 295
Alphonse
  • 61
  • 1
  • 8

1 Answers1

2

you need to use concatenation:

echo "<tr><td>" . $cv['cv'] . "</td><td>" . getUsernameById($cv['senderid']) . "</td></tr>";
Iłya Bursov
  • 23,342
  • 4
  • 33
  • 57
  • 1
    I would add that the problem is not related to the `` but actually "calling a function inside an `echo` statement in php". – Dekel Dec 30 '16 at 20:51