Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display MySQL data in a list

Tags:

html

php

mysql

I will be using data from a MySQL database and to receive that data I will be using this code:

SELECT link, notes FROM links WHERE useri_id=XXX;

I am now stuck on how to display this nicely in a list where it will be a link and then on next line the notes for that link and then a spacer line and then it will display the next link and notes and so on. How would I code this?

like image 977
Will Evans Avatar asked Nov 28 '25 03:11

Will Evans


1 Answers

You can use something like this:

$rs = mysql_query("SELECT link, notes FROM links WHERE useri_id=XXX") or die(mysql_error());

echo "<ul>";
while( false !== ($row = mysql_fetch_assoc($rs)))
{
  echo "<li>";
  echo "<a href='" . $row['link'] . "'>" . $row['link'] . "</a><br />";
  echo $row['notes'] . "<hr />";
  echo "</li>";
}
echo "</ul>";
like image 98
ariefbayu Avatar answered Nov 29 '25 16:11

ariefbayu