I have this PHP snippet that makes an <li>
with some id which is chosen by mysqli_query
fetched row. It looks like this:
while($row=mysqli_fetch_array($run_query)){
$name=$row['company_name'];
echo "<li><a href='#' id=".$name." class='category_sidebar2'>$name</a></li>";
}
When the $name
is a single entity like Dell or Facebook, it creates the <li>
just fine, but when the $name
is a space-separated value like "Tata Steel" or something, it creates the <li>
with the id
just the first value before the space.
For example, if $name
is "Tata Steel", it echoes
<li><a href='#' id='Tata'></li>
and not
<li><a href='#' id='Tata Steel'></li>
How do I get around this?