cvs: php-hosts-web /msgboard index.php shared-msgboard.inc /msgboard/etc index.php
| From: | jim winstead | Date: | Mon, 22 Apr 2002 01:09:28 +0000 |
| Subject: | cvs: php-hosts-web /msgboard index.php shared-msgboard.inc /msgboard/etc index.php | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-9743@lists.php.net to get a copy of this message | ||
jimw Sun Apr 21 21:09:28 2002 EDT
Modified files:
/php-hosts-web/msgboard index.php shared-msgboard.inc
/php-hosts-web/msgboard/etc index.php
Log:
more code consolidation. only display 30 entries at a time in the index.
Index: php-hosts-web/msgboard/index.php
diff -u php-hosts-web/msgboard/index.php:1.1 php-hosts-web/msgboard/index.php:1.2
--- php-hosts-web/msgboard/index.php:1.1 Sun Apr 21 16:58:04 2002
+++ php-hosts-web/msgboard/index.php Sun Apr 21 21:09:27 2002
@@ -3,69 +3,65 @@
commonHeader("Message Board");
?>
<h3>Message Board</h3>
-<? introText(); ?>
+<P>
+This message board has been developed so that users can comment on the hosting
+companies listed on this site. Try and keep your comments on-topic, and free
+of inappropriate language.
+</P>
<P>
Click on <? echo $IMG_SHOW; ?> for a listing of all the comments for a particular <? echo
$SUBGROUP_TITLE; ?>.
To add your own comments, click on <? echo $IMG_ADD; ?>.
</P>
<?
+$begin = (int)$begin;
+
+$query = 'SELECT SQL_CALC_FOUND_ROWS HostId,HostName,'
+ . 'COUNT(date) AS count,MAX(date) AS last'
+ . ' FROM hosts LEFT JOIN msgboard_msgs ON HostId = subgroup'
+ . ' GROUP BY HostId ORDER BY TRIM(HostName) LIMIT '.$begin.',30';
+
+$res = mysql_query($query) or die("query failed: ".mysql_error());
+$end = $begin + mysql_num_rows($res);
+
+$total = mysql_get_one("SELECT FOUND_ROWS()");
+
+echo "Displaying ", $begin + 1, " to ", $end, " of ", $total;
+echo "<br /><a href=\"index.php?begin=$end\">Display next
30</a>";
+
echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH=100%>\n";
echo "<TR BGCOLOR=\"$MSG_FRAME_COLOR2\" VALIGN=bottom>\n";
echo "<TD ALIGN=left>";
-font("-1");
echo $SUBGROUP_TITLE."</TD>\n";
echo "<TD ALIGN=center>";
-font("-1");
echo "Number of<BR>Messages</TD>\n";
echo "<TD ALIGN=center>";
-font("-1");
echo "Latest<BR>Message</TD>\n";
echo "<TD><BR></TD>\n";
echo "<TD><BR></TD>\n";
echo "</TR>\n";
-$i=0;
-while (list($id,$section)=each($SUBGROUP)):
+while ($host = mysql_fetch_assoc($res)) {
$bg=$BGCOLOR[$i%2];
echo "<TR BGCOLOR='$bg' VALIGN=middle>\n";
- echo "<TD>";
- font("");
- echo $section."<BR></TD>\n";
-
- $query="select count(id) as count, max(date) as last";
- $query.=" from msgboard_msgs";
- $query.=" where subgroup=".$id;
- echo "<!-- $query -->\n";
- $q2=mysql_db_query($DBASE,$query);
- $count=mysql_result($q2,0,"count");
- $last=date("d-M-Y",mysql_result($q2,0,"last"));
- if ($count==0):
- $last="-";
- else:
- endif;
- mysql_free_result($q2);
+ echo "<td>", htmlentities($host['HostName']), "</td>\n";
+ $last=$host['count'] ? date("d-M-Y",$host['last']) : '-';
echo "<TD ALIGN=right>";
- font("-1");
- echo "$count<BR></TD>\n";
+ echo "$host[count]<BR></TD>\n";
echo "<TD ALIGN=center>";
- font("-1");
echo "$last<BR></TD>\n";
- echo "<TD>";
- font("-1");
- if ($count!=0):
- echo "<A HREF=\"list.php?subgroup=" .$id . "\">" . $IMG_SHOW
. "</A>";
+ echo "<td>";
+ if ($host['count']):
+ echo "<A HREF=\"list.php?subgroup=$host[HostId]\">" . $IMG_SHOW .
"</A>";
endif;
- echo "<BR></TD>";
+ echo "</td>";
- echo "<TD>";
- font("-1");
- echo "<A HREF=\"post.php?subgroup=" . $id . "\">" . $IMG_ADD .
"</A>";
- echo "<BR></TD>";
+ echo "<td>";
+ echo "<A HREF=\"post.php?subgroup=$host[HostId]\">" . $IMG_ADD .
"</A>";
+ echo "</TD>";
echo "</TR>\n";
- $i++;
-endwhile;
+}
echo "</TABLE>\n";
commonFooter();
?>
Index: php-hosts-web/msgboard/shared-msgboard.inc
diff -u php-hosts-web/msgboard/shared-msgboard.inc:1.8
php-hosts-web/msgboard/shared-msgboard.inc:1.9
--- php-hosts-web/msgboard/shared-msgboard.inc:1.8 Sun Apr 21 20:52:17 2002
+++ php-hosts-web/msgboard/shared-msgboard.inc Sun Apr 21 21:09:27 2002
@@ -48,16 +48,8 @@
$SUBGROUP_TITLE = "Hosting Company";
-$query = "select * from $HOSTS_TABLE order by HostName";
-$q1 = mysql_db_query($DBASE,$query) or die($query.": ".mysql_error());
-while ($result=mysql_fetch_array($q1)) {
- $SUBGROUP[$result["HostID"]] = $result["HostName"];
-}
-mysql_free_result($q1);
-
function getSubgroupName($id) {
- global $SUBGROUP;
- return $SUBGROUP[$id];
+ return mysql_get_one("SELECT HostName FROM hosts WHERE HostId=$id");
}
@@ -95,18 +87,6 @@
$IMG_ADD = "<b>Add</b>";
/* FUNCTION DEFINITIONS */
-
-function introText () {
-/*
- * Intro blurb on the intro page
- */
-?>
-<P>
-This Message Board has been developed so that users can comment on the hosting companies
-listed on this site. Try and keep your comments on-topic, and free of inappropriate language.
-</P>
-<?
-};
function makeIndent($x) {
$return="<IMG SRC=\"/gifs/spacer.gif\" ALT=\" \" WIDTH=8 HEIGHT=18
BORDER=0 ALIGN=top>";
Index: php-hosts-web/msgboard/etc/index.php
diff -u php-hosts-web/msgboard/etc/index.php:1.2 php-hosts-web/msgboard/etc/index.php:1.3
--- php-hosts-web/msgboard/etc/index.php:1.2 Sun Apr 21 20:48:39 2002
+++ php-hosts-web/msgboard/etc/index.php Sun Apr 21 21:09:28 2002
@@ -3,7 +3,6 @@
require 'login.inc';
commonHeader("Moderate Message Board");
title("Moderate Message Board");
-introText();
?>
Click on the <? echo $IMG_SHOW; ?> button for a listing of all the comments for a particular
section.
<P>