-1

I have a value in a (single column) mySQL database which reads similar to this.

Entry1,Entry2,Entry3

I need to echo them in an unordered list. I had a look possible how can I query the database. Tried following (referencing an answer here) but keep getting and SQL error which essentially seems like an issue with the query.

 $SQL = "SELECT mytableColumn(SUBSTR(mytableColumn, 0, INSTR(mytableColumn, ',')-1), mytableColumn) AS output
  FROM mytableColumn";

Can you help?

mickmackusa
  • 43,625
  • 12
  • 83
  • 136
Mohan Wijesena
  • 225
  • 1
  • 3
  • 11

1 Answers1

0

I would simplify the query to just SELECT columnName FROM tableName and get the result as a string.

You can then use the PHP explode function like:

$resultsArray = explode(',', $stringResult);

and from there:

<ul>
    <?php foreach($resultsArray as $item): ?>
        <li><?= $item ?></li>
    <?php endforeach; ?>
</ul>
Jason Papp
  • 41
  • 1
  • 7