2004-07-13, 09:28 AM
Pages: 1 2
2004-07-13, 04:18 PM
Well.. here it is! It still needs formatting though, so if you could put it in a nice table and maybe repost it.. that'd be great!
Here it is:
You could probablt cut out half of that code, but im new to PHP.
Here it is:
Code:
<?
include("url to functions.php");
mysql_connect('host', 'user', 'pass');
mysql_select_db('db');
$query = mysql_query("SELECT t.*, u.username FROM threads t LEFT JOIN users u ON (u.uid=t.uid) WHERE 1=1 AND t.visible='1' AND t.closed NOT LIKE 'moved|%' ORDER BY t.lastpost DESC LIMIT 0, 10");
while($thread = mysql_fetch_array($query))
{
if($thread['lastpost'] != "" && $thread['lastposter'] != "")
{
$lastpostdate = mydate("dS of F Y", $thread['lastpost']);
$lastposttime = mydate("h:i:s A", $thread['lastpost']);
eval("\$lastpost = \"".("<html><body><i>Last Post by:</i> <a href=forum/member.php?action=profile&uid=lastposter&tid=$thread[tid] target=center> $thread[lastposter]</a><br />
$lastpostdate $lastposttime<br /></body></html>")."\";");
}
else
{
$lastpost = "";
}
$thread['subject'] = stripslashes($thread['subject']);
if(strlen($thread['subject']) > 25)
{
$thread['subject'] = substr($thread['subject'], 0, 25) . "...";
}
$thread['subject'] = htmlspecialchars($thread['subject']);
eval("\$threadlist .= \"".("<html><body><tr>
<td class=$altbg>
<b><a href=forum/showthread.php?tid=$thread[tid] target=center> $thread[subject]</a></b><span class=smalltext><br />
$lastpost
<b>� </b>Replies: $thread[replies]<br />
<b>� </b>Views: $thread[views]
</td>
</tr></body></html>")."\";");
if($altbg == "trow1")
{
$altbg = "trow2";
}
else
{
$altbg = "trow1";
}
}
eval("\$latestthreads = \"".("<html><body><table cellspacing=0 cellpadding=0 border=0 width=100%>
<tr>
<td class=tborder>
<table border=0 cellspacing=$theme[borderwidth] cellpadding=$theme[tablespace] width=100%>
<tr>
<td class=thead><b>Latest Threads</b></td>
</tr>
$threadlist
</table>
</td></tr></table>
<br></body></html>")."\";");
print "$latestthreads";
?>
You could probablt cut out half of that code, but im new to PHP.
2004-07-15, 07:18 AM
I took what you had and I modified it to suit my purposes. I also made it a little easier, you can change things in the admin cp and it should still work without needing to be modified.
<?php
include("inc/functions.php"); // Path to Functions.php
include("inc/config.php"); // Path to Config.php
include("inc/settings.php"); // Path to Settings.php
mysql_connect($config[hostname], $config[username], $config[password]);
mysql_select_db($config[database]);
$query = mysql_query("SELECT t.*, u.username FROM threads t LEFT JOIN users u ON (u.uid=t.uid) WHERE 1=1 AND t.visible='1' AND t.closed NOT LIKE 'moved|%' ORDER BY t.lastpost DESC LIMIT 0, 10");
while($thread = mysql_fetch_array($query))
{
if($thread['lastpost'] != "" && $thread['lastposter'] != "")
{
$lastpostdate = mydate("dS of F Y", $thread['lastpost']);
$lastposttime = mydate("h:i:s A", $thread['lastpost']);
eval("\$lastpost = \"".("<a href=$settings[bburl]member.php?action=profile&uid=lastposter&tid=$thread[tid]> $thread[lastposter]</a>")."\";");
}
else
{
$lastpost = "";
}
$thread['subject'] = stripslashes($thread['subject']);
if(strlen($thread['subject']) > 25)
{
$thread['subject'] = substr($thread['subject'], 0, 25) . "...";
}
$thread['subject'] = htmlspecialchars($thread['subject']);
eval("\$threadlist .= \"".("<tr>
<td><b><a href=$settings[bburl]showthread.php?tid=$thread[tid]> $thread[subject]</a></b></td>
<td>$lastpost </td>
<td>$thread[replies] </td>
<td>$thread[views] </td>
</tr>")."\";");
if($altbg == "trow1")
{
$altbg = "trow2";
}
else
{
$altbg = "trow1";
}
}
eval("\$latestthreads = \"".("<table border=0 cellspacing=$theme[borderwidth] cellpadding=$theme[tablespace] width=100%>
<tr>
<td><b>Thread</b></td>
<td><b>Posted by</b></td>
<td><b>Replies</b></td>
<td><b>Views</b></td>
</tr>
$threadlist
</table>")."\";");
print "$latestthreads";
?>
2005-02-12, 07:20 AM
just recently registered. i added the this to the main area of the forum. and it doesn't seem to be showing anything by any chance do i need to add mysql information in these areas?
mysql_connect($config[hostname], $config[username], $config[password]);
mysql_select_db($config[database]);
2005-02-15, 01:11 AM
i don't mean to double post. but im wondering if any one can help me out with this. does this code actually work and can someone assist me on what am i doing wrong?
2005-05-26, 12:32 PM
Doesn't work for me either :'(
2005-05-26, 12:41 PM
If you added it to the template, you can't add connection code to the template bits.
If you edited PHP files, and it's in a function, then you need to make $config global by adding
If you edited PHP files, and it's in a function, then you need to make $config global by adding
global $config;
underneath the function heading. 2005-05-26, 01:03 PM
i have no idea what you just said decswxaqz.
What I did is take the code supplied in post #13 by TemplatesForAll and paste it in a new .php file called test1.php.
I placed test1.php in my forum root folder.
When I call the page from the browser it doesn't show anything, not even errors or warnings. Just a plain white page.
Hope that info helps? Thanks in advance.
What I did is take the code supplied in post #13 by TemplatesForAll and paste it in a new .php file called test1.php.
I placed test1.php in my forum root folder.
When I call the page from the browser it doesn't show anything, not even errors or warnings. Just a plain white page.
Hope that info helps? Thanks in advance.
2005-05-27, 12:57 AM
could someone explain what does this "mod" do?
Maybe I'm interested too
Thank you guys
Maybe I'm interested too
Thank you guys
Pages: 1 2