DionDev
09-21-2008, 03:53 PM
I am looking for some help with this. Now it works, but it doesn't seem to be as efficient as I would like it to be. I mean sometimes it takes a couple of seconds to display the page. The execution time is what I am worried about.
Could any PHP gurus give some input as to how I could improve this news page script I wrote? (it grabs news from a specified forum and spits it out onto a php page)
<?php
chdir('./forums');
require_once('./global.php');
require_once('./includes/class_bbcode.php');
$parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$dbhost = 'localhost';
$dbname = '*****';
$dbuser = '*****';
$dbpass = '*****';
mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
$sql = 'SELECT post.pagetext, thread.*
FROM post AS post, thread AS thread
LEFT JOIN forum AS forum ON (forum.forumid = thread.forumid)
WHERE FIND_IN_SET(4, forum.parentlist) AND post.postid = thread.firstpostid
ORDER BY thread.dateline DESC
LIMIT 5';
$sqlresult = mysql_query($sql) or die(mysql_error());
$count = mysql_num_rows($sqlresult);
while ($row = mysql_fetch_array($sqlresult))
{
$subject = $row['title'];
$poster = $row['postusername'];
$posterid = $row['postuserid'];
$time = date("D, M j, Y", $row['dateline']);
$replies = $row['replycount'];
$id = $row['threadid'];
$text = $parser->do_parse($row['pagetext'], true, true, true, true, true, false);
if ($replies == 1)
$replytext = 'reply';
else
$replytext = 'replies';
echo "<b>$subject</b>";
echo '<br>';
echo '<font style="font-size: 8pt;">';
echo "Posted by <a href=\"forums/member.php?u=$posterid\">$poster</a> on $time (<a href=\"forums/showthread.php?t=$id\">$replies $replytext</a>)";
echo '</font>';
echo '<br><br>';
echo $text;
}
echo '<br><br><div style="float: right;"><a href="forums/forumdisplay.php?f=4">News Archive Forum</a></div>';
?>
Could any PHP gurus give some input as to how I could improve this news page script I wrote? (it grabs news from a specified forum and spits it out onto a php page)
<?php
chdir('./forums');
require_once('./global.php');
require_once('./includes/class_bbcode.php');
$parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$dbhost = 'localhost';
$dbname = '*****';
$dbuser = '*****';
$dbpass = '*****';
mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
$sql = 'SELECT post.pagetext, thread.*
FROM post AS post, thread AS thread
LEFT JOIN forum AS forum ON (forum.forumid = thread.forumid)
WHERE FIND_IN_SET(4, forum.parentlist) AND post.postid = thread.firstpostid
ORDER BY thread.dateline DESC
LIMIT 5';
$sqlresult = mysql_query($sql) or die(mysql_error());
$count = mysql_num_rows($sqlresult);
while ($row = mysql_fetch_array($sqlresult))
{
$subject = $row['title'];
$poster = $row['postusername'];
$posterid = $row['postuserid'];
$time = date("D, M j, Y", $row['dateline']);
$replies = $row['replycount'];
$id = $row['threadid'];
$text = $parser->do_parse($row['pagetext'], true, true, true, true, true, false);
if ($replies == 1)
$replytext = 'reply';
else
$replytext = 'replies';
echo "<b>$subject</b>";
echo '<br>';
echo '<font style="font-size: 8pt;">';
echo "Posted by <a href=\"forums/member.php?u=$posterid\">$poster</a> on $time (<a href=\"forums/showthread.php?t=$id\">$replies $replytext</a>)";
echo '</font>';
echo '<br><br>';
echo $text;
}
echo '<br><br><div style="float: right;"><a href="forums/forumdisplay.php?f=4">News Archive Forum</a></div>';
?>