topical media & game development
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(row['name']) .
"</div>";
echo "<div class=\"pubdate\">";
if (row['date_published']));
} else {
echo "not yet published";
}
echo "</div></h5>\n";
if (row['body'])));
echo "</p>\n";
echo "<h4><a href=\"viewarticle.php?article=" .
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 (result) . " Comments";
if (isset(is_published) {
echo " / <a href=\"comment.php?article=" . result)) {
echo "<div class=\"scroller\">\n";
while (result)) {
echo "<span class=\"commentName\">" .
htmlspecialchars(row['comment_date'])) .
")</span>\n";
echo "<p class=\"commentText\">\n" .
nl2br(htmlspecialchars(
(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.