TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,970
  • Latest: bynw
Stats
  • Total Posts: 196,046
  • Total Topics: 21,335
  • Online today: 319
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 326
  • Total: 326

top posters blk needs edit

Started by Assistance, January 22, 2007, 10:49:28 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Assistance

$numberofposters = 5; // You can change this to however many you want

require_once "SSI.php";
$top_posters = ssi_topPoster($numberofposters, "return");

foreach ($top_posters as $poster)
{
  echo $poster['link'] , ' (', $poster['posts'] , ')<br />';
}



how do i put that into a table ( i cant mix and match php with html : (
to look like
name       #
name       #
name       #
name       #

currenty it is

name(#)
name(#)
name(#)
name(#)

JPDeni

Let's take the opportunity to do a little tutorial here.

Quote
i cant mix and match php with html
Sure you can! :)

The code that prints it out is


foreach ($top_posters as $poster)
{
  echo $poster['link'] , ' (', $poster['posts'] , ')<br />';
}


Right? Right there is a mix of php and html. But we're going to do a little more.

You want a table. So, the first thing you need to do is to start a table. Since you're using php, you use an echo statement:


echo '<table>';


Now we want to print out each of the top posters. We already have the loop to copy. We just need to change it so that each poster is in it's own row and the poster and number of posts are in their own cells.


foreach ($top_posters as $poster)
{
  echo '<tr><td>', $poster['link'] , '</td><td>', $poster['posts'] , '</td></tr>';
}


Then we close off the table.


echo '</table>';


Easy-peasy!!  :)

Putting it all together ....


echo '<table>';
foreach ($top_posters as $poster)
{
  echo '<tr><td>', $poster['link'] , '</td><td>', $poster['posts'] , '</td></tr>';
}
echo '</table>';



Now you'll be able to do the next one on your own!!!  ;D

Assistance

someone deleted my thank you reply :(


......thank you

JPDeni


Lord Anubis

#4
I am currently using this...is there a way to add member group colors by adding say
global $sourcedir to the code? or how would I go about that currently my code is
$numberofposters = 10; // You can change this to however many you want

require_once "SSI.php";
$top_posters = ssi_topPoster($numberofposters, "return");

echo '<table>';
foreach ($top_posters as $poster)
{
  echo '<tr><td>', $poster['link'] , '</td><td>',   '</td><td>',  '</td><td>',  '</td><td>',  '</td><td>',  '</td><td>',  '</td><td>',  '</td><td>',   '</td><td>','</td><td>',$poster['posts'] , '</td></tr>';
}
echo '</table>';

I know it isn't clean with all those '</td><td>' , if that could be cleaned up to make the name left aligned and the posts right aligned would be better...Also if there is a way to show the last posts of that user in the number of posts would be good
I guess it would be linked to
http://yoursite.com?action=profile;u=?;sa=showPosts...I dunno if this is possible....

Thanks for the help in advance,
LA

knat

QuoteAlso if there is a way to show the last posts of that user in the number of posts would be good
I guess it would be linked to
http://yoursite.com?action=profile;u=?;sa=showPosts...I dunno if this is possible....


somebody did this to the postercloud snippet.. go and check it out maybe you can figure out how to apply it to this snippet  :) i dont think you need to change much to do so  ;)

Lord Anubis

Thanks...I will take a look at that!

Lord Anubis


This website is proudly hosted on Crocweb Cloud Website Hosting.