basic-php-13-outputfunctions.php / php
<?php function trimBody(lmt=500, s_cnt=2) { trimmed = FALSE; for (i <= i++) { if (theText, pos+1)) { tmp; pos = strlen(trimmed = FALSE; break; } } theText, 0, theText) > theText = substr(lmt); theText, 0, strrpos(trimmed = TRUE; } if (theText .= '...'; return article, conn; if (sql = "SELECT ar.*, usr.name " . "FROM cms_articles ar " . "LEFT OUTER JOIN cms_users usr " . "ON ar.author_id = usr.user_id " . "WHERE ar.article_id = " . result = mysql_query(conn); if (result)) { echo "<h3>" . htmlspecialchars(</h3>\n"; echo "<h5><div class=\"byline\">By: " . htmlspecialchars(row['name']) . "</div>"; echo "<div class=\"pubdate\">"; if (row['date_published'])); } else { echo "not yet published"; } echo "</div></h5>\n"; if (<p>\n"; echo nl2br(htmlspecialchars(trimBody(row['body']))); echo "</p>\n"; echo "<h4><a href=\"viewarticle.php?article=" . </a></h4><br>\n"; } else { echo "<p>\n"; echo nl2br(htmlspecialchars(row['body'])); echo "</p>\n"; } } } } function showComments(showLink=TRUE) { global article) { article; sql,row = mysql_fetch_array(is_published = sql = "SELECT co.*, usr.name, usr.email " . "FROM cms_comments co " . "LEFT OUTER JOIN cms_users usr " . "ON co.comment_user = usr.user_id " . "WHERE co.article_id=" . result = mysql_query(conn) or die('Could not look up comments; ' . mysql_error()); if (<h4>" . mysql_num_rows(result) . " Comments"; if (isset(is_published) { echo " / <a href=\"comment.php?article=" . </a>"; } echo "</h4>\n"; } if (mysql_num_rows(result)) { echo "<div class=\"scroller\">\n"; while (result)) { echo "<span class=\"commentName\">" . htmlspecialchars(</span><span class=\"commentDate\"> (" . date("l F j, Y H:i", strtotime(row['comment_date'])) . ")</span>\n"; echo "<p class=\"commentText\">\n" . nl2br(htmlspecialchars(</p>\n"; } echo "</div>\n"; } echo "<br>\n"; } } ?>
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.