在特定字符前打印所有单词

Im having a problem with my function.

  1. The user is able to post text to the page and set categories to the article. categories that is set is saved in mysql in this way: categorie1,categorie2,categorie3

So, I want my visitors to be able to choose categories by providing a list with all categories.

This is how im thinking:

  <?php
  $sql02 = "SELECT * FROM article ORDER BY id";
  $result02 = mysql_query($sql02); 


  while($rad02 = mysql_fetch_array($result02))
  {
  ?>

  <?php

      $before = "<li><a href='index.php?p=cmd&kat=TEST'>";
      $string =  $rad02["kategori"];
      $newstring = str_ireplace(",", "<br>", $string);
      $kat = $newstring;

  ?>
      <li><a href='index.php?p=cmd&kat=<?php echo $kat; ?>'><php echo "$kat"; ?></a></li>

  <?php
      }
  ?>

But that does not work.. what am I doing wrong?

You don't need $kat = $newstring; and when you said echo "$kat"; you shouldn't put $kat into ""

Hope this helps

If every categorie has it's own id you can do this than with foreach loop like this

while($rad02 = mysqli_fetch_array($result02)){
$rads[] = $rad02;
}
foreach($rads = $rad02){
?>
<li><a href='index.php?p=cmd&kat=<?php echo $rad02['kategori']; ?>'><?php echo $rad02['karegori']; ?></a></li>
<?php } ?>