1

So I'm writing a php project and I got stuck on hyphens in column names of a table in a database. I have the following code:

 $results = $conn->query($sql)->fetchAll(PDO::FETCH_OBJ);
     foreach ($results as $row) { ?>
      <tr>
        <td><a href="#<?= $row->factuur-status ?>"><?= $row->factuur-status ?></a></td>
        <td><?= $row->verkoop-orderid ?></td>
      </tr>
<?php } ?>

Now obviously because of the hyphens in the column names this doesn't work. How can one fix this?

Ken
  • 2,859
  • 4
  • 24
  • 26

1 Answers1

1

I found it, if someone's interested:

<?= $row->{'factuur-status'} ?>
Ken
  • 2,859
  • 4
  • 24
  • 26