Php fetch array

by 3 replies
4
Hi guys beautiful salutation to you all.
i want to fetch array from mysql db using <li>, and i want each <li> element to have a unique url. but i don't know how to go about it. Please i need help.


<?php

$match=mysql_query("SELECT Name FROM camp")or die("can't get result");
while($row=mysql_fetch_array($match)){
echo '<li id="people">'.'<a href="#">'. $row['Name'].'</a>'.'</li>';
}?>
#programming #array #fetch #php
  • Well you can't have your li elements having the same ID, which is what you are doing - use classname instead.

    As for a unique url for the links, you have a couple options. Is the 'name' field unique? then you could use that. Otherwise you should have a unique ID field in your database, you can use that.
    • [ 1 ] Thanks
  • change '<li id="people">' to <li class="people">'
  • Special thanks to Andrew H and donMhico.

Next Topics on Trending Feed

  • 4

    Hi guys beautiful salutation to you all. i want to fetch array from mysql db using <li>, and i want each <li> element to have a unique url. but i don't know how to go about it. Please i need help.