I have this query
$people = "SELECT name FROM people";
$people = mysql_query($people) or die(mysql_error());
$row_people = mysql_fetch_assoc($people);
$totalRows_people = mysql_num_rows($people);
I can echo the results within a unordered list using a while loop like this
<ul>
<?php {do { ?>
<li><?php echo $row_people['name'];?></li>
<?php } while ($row_people = mysql_fetch_assoc($people));}?>
</ul>
But I can't used this as my html does not allow it.
<ul>
<li class="first">
<a href="?name=kate">Kate</a>
<li>
<li class="second">
<a href="?name=john"><img src="john.jpg" />John</a>
<li>
<li class="third">
<a href="?name=max"><span>Max</span></a>
<li>
</ul>
My question is how can echo the name that was retrieved from the database into the appropriate place within this html?
Thanks for your help.
<?php ?>tags in your code. However, are you saying that you want to output markup like what is in the block of markup? Meaning, you're asking how to adjust it to suit this markup?<?php echo $row_people['name'] ?>is a XSS security hole. Always escape all output that you echo to html using the function htmlentities(), like so:<?php echo htmlentities($row_people['name']); ?>