3 replies
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>';
}?>
#array #fetch #php
  • Profile picture of the author Andrew H
    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.
    Signature
    "You shouldn't come here and set yourself up as the resident wizard of oz."
    {{ DiscussionBoard.errors[8753573].message }}
  • Profile picture of the author donMhico
    change '<li id="people">' to <li class="people">'
    {{ DiscussionBoard.errors[8753726].message }}
  • Profile picture of the author heroecitadel
    Special thanks to Andrew H and donMhico.
    {{ DiscussionBoard.errors[8754916].message }}

Trending Topics