display data from myusql

/ Published in: PHP
Save to your folder(s)

Copy this code and paste it in your HTML
  1. $query = 'SELECT field1, field2 FROM thisTable ORDER BY dateline LIMIT 5';
  2. $result = mysql_query($query);
  3. $items = array();
  4. while ($row = mysql_fetch_assoc($result)) {
  5. $items[] = sprintf('<li><a href="%s">%s</a></li>', $row['field1'], $row['field2']);
  6. }
  7. //do something with $items array;

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.