----- Original Message ----- 
From: Mark Mckee 
The data is read from the database and outputted as so:
-------------------------------------------------
<?php
$con = mysql_connect("******",""******",""******");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db(""******", $con);
$query.=" DATE_FORMAT(entrydate, '%M %d, %Y') AS date";
$result = mysql_query("SELECT * FROM info ORDER BY id DESC");

while($row = mysql_fetch_array($result))
{ 
$date = $row["date"];
$class = $row["class"];
$url = $row["url"];
$title = $row["title"];
$comment = $row["comment"];

echo "<li class='$liclass'><a href='$url' target='_blank'>$title</a>.<br 
/> $comment </li>"; ; echo "\n";
}
mysql_close($con);
?>
<?php
echo '</ul>';
?>
-------------------------------------------------
tuesday 2nd
link
link

monday 1st
link
link
-------------------------------------------------
==============================================


Hi Mark,

<?php
$con = mysql_connect('localhost', 'root', '');
if (!$con) die('Could not connect to DB');
mysql_select_db('mytest', $con);

$sql = "SELECT
  DATE_FORMAT(id, '%W %D') AS mydate,
  class, url, title, comment
  FROM info
  ORDER BY id DESC";
$result = mysql_query($sql) or die('Error: Get All');

echo "<dl>\n";
$temp = "";
while ($row = mysql_fetch_assoc($result)) {
  $date = $row['mydate'];
  $class = $row['class'];
  $url = $row['url'];
  $title = $row['title'];
  $comment = $row['comment'];

  if ($date != $temp) echo "<dt>$date</dt>\n";
  $temp = $date;
  echo "<dd class='$class'><a href='$url' target='_blank'>$title</a></dd>\n";
  echo "<dd>$comment</dd>\n";
}
echo "</dl>\n";
mysql_close($con);
?>

This formats it in the way you showed.
It depends on how you've set up your DB fields.

It's geting the date from the id, so I haven't used a date field.
Have used a <dl> is it's easier to split up and style.
Not sure what you're using $class for. Does it change?

This is the table used in my test and probably different to yours:

CREATE TABLE `info` (
  `id` datetime NOT NULL default '0000-00-00 00:00:00',
  `class` text NOT NULL,
  `url` text NOT NULL,
  `title` text NOT NULL,
  `comment` text NOT NULL,
  KEY `id` (`id`)
) TYPE=MyISAM;

Regards, Bob E.




Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/php-list/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to