0

How do I split separated by comma values, and echo them as a different links?

what i have now what do i want

<?php

$servername = "localhost"; $username = "root"; $password = ""; $dbname = "mydb";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT item FROM mytable where id = 26";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {

echo "<p> <a href=http://localhost/items.php?item=".$row["item"]."><span class=link>".$row["item"]."</span></a> </p>";             
}

}else {
echo "0 results";
}

$conn->close();
?>

How do I use substring_index here?

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • see this descussion https://stackoverflow.com/questions/3653462/is-storing-a-delimited-list-in-a-database-column-really-that-bad when you for cimma seperated into rows yoz will find an answer – nbk Jul 04 '20 at 19:41
  • Don't store the values in a delimited string in a single column. – Shadow Jul 04 '20 at 19:58

0 Answers0