Jump to content
MakeWebGames

Recommended Posts

Posted

Re: forum posts

ok ive probably gone about this all wrong but am i anywhere near when i use this code

<?php

/**
* @author Blackdogg
* @copyright 2009
*/
include "globals.php";
switch($_GET['action'])

{
case "forum":
forum();
break;
}
function forum()
{
global $db,$ir,$c,$userid, $myf;
print "Showing the last 10 forum posts

<table width=75% cellspacing=1 class='table'><tr style='background:gray'> 
select topic from forum_topics order by last_post_date desc limit 10
";
}
print "</table>";
?>

ive put a link onto the homepage to take you to a new page (code above)

Be gentle with me im still learning :p

Posted

Re: forum posts

 

ok ive probably gone about this all wrong but am i anywhere near when i use this code

<?php

/**
* @author Blackdogg
* @copyright 2009
*/
include "globals.php";
switch($_GET['action'])

{
case "forum":
forum();
break;
}
function forum()
{
global $db,$ir,$c,$userid, $myf;
print "Showing the last 10 forum posts

<table width=75% cellspacing=1 class='table'><tr style='background:gray'> 
select topic from forum_topics order by last_post_date desc limit 10
";
}
print "</table>";
?>

ive put a link onto the homepage to take you to a new page (code above)

Be gentle with me im still learning :p

Rofl.

Try this

 

<?php
require_once("globals.php");

echo 'Showing the last 10 forum posts
';
mysql_query("SELECT `topic` FROM `forum_topics` ORDER BY `last_post_date` DESC LIMIT 10");
/*
-- Show your stuff here!!
*/
?>

 

Or this is yours i done:

 

<?php
requre_once("globals.php");
$_GET['action'] = isset($_GET['action']) && is_string($_GET['action']) ? trim(strtolower($_GET['action'])) : "";
switch($_GET['action'])
{
   case "forum":
   forum();
   break;
}
function forum()
{
global $db,$ir,$c,$userid, $myf;
print "Showing the last 10 forum posts

<table width=75% cellspacing=1 class='table'><tr style='background:gray'>";
mysql_query("SELECT `topic` FROM `forum_topics` ORDER BY `last_post_date` DESC LIMIT 10");
/*
-- Show your stuff here!!
*/
}
print "</table>";
?>
Posted

Re: forum posts

 

Should use include_once() :wink:

Can use any i want :wink: when using require_once if it dont find file page dies :P thats why i use that some times.

Posted

Re: forum posts

When I said: "select topic from forum_topics order by last_post_date desc limit 10", keep in mind that I don't know how your forum is setup. I don't know what the table names or column names are.

I don't even know if it uses a database in the first place.

The mysql query I posted is *representative* of how a query could be crafted that would get the last 10 topics posted in.

 

I will say that your code is a long way off from what it needs to be, if indeed you are getting your data from a database.

Posted

Re: forum posts

 

<?php
include_once(DIRNAME(__FILE__) . '/globals.php');

echo 'Showing the last 10 forum posts! 

<table border="1" width="85%" class="table" cellspacing="0" cellpadding="2">
<tr style="text-align:center;">
	<th>Topic</th>
	<th>Posts</th>
	<th>Started</th>
	<th>Last Post</th>
</tr>';

$Select = $db->query("SELECT `ft_id`, `ft_name`, `ft_desc`, `ft_posts`, `ft_owner_id`, `ft_owner_name`, `ft_start_time`, `ft_last_id`, `ft_last_name`, `ft_last_time` FROM `forum_topics` ORDER BY `ft_last_time` DESC LIMIT 10");

while ($r = $db->fetch_row($Select))
{
echo '
<tr style="text-align:center;">
	<td>
		[url="forums.php?viewtopic='.intval($r['ft_id']).'&lastpost=1"]'.stripslashes($r['ft_name']).'[/url]

		[size="1"]'.stripslashes($r['ft_desc']).'[/size]
	</td>
	<td>
		'.number_format($r['ft_posts']).'
	</td>
	<td>
		'.date('F j Y, g:i:s a', $r['ft_start_time']).'

		By: [url="viewuser.php?u='.intval($r['ft_owner_id']).'"]'.stripslashes($r['ft_owner_name']).'[/url]
	</td>
	<td>
		'.date('F j Y, g:i:s a', $r['ft_last_time']).'

		By: [url="viewuser.php?u='.intval($r['ft_last_id']).'"]'.stripslashes($r['ft_last_name']).'[/url]
	</td>
</tr>';
}
echo '
</table>';

$h->endpage();
?>

 

I think... :wink:

Posted

Re: forum posts

 

$Select = $db->query("SELECT `ft_id`, `ft_name`, `ft_desc`, `ft_posts`, `ft_owner_id`, `ft_owner_name`, `ft_start_time`, `ft_last_id`, `ft_last_name`, `ft_last_time` FROM `forum_topics` ORDER BY `ft_last_time` DESC LIMIT 10");

How come its going off the page ? lol

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...