MySQL Forums
Forum List  »  Spanish

Como hacer uan consulta a mysql
Posted by: Carles Garcia
Date: October 08, 2011 06:26AM

Hola,

Tengo un foro phpbb3 con una base de datos en mysql y en una de las tablas llamada phpbb_users tengo un valor llamado user_reputation que me gustaria poner un bloque en el foro donde aparezca el ranking de los5 usuarios con mejor reputación y los 3 con peores reputación.

He intentado definirlo así en un bloque pero nada, lo he copiado de un listado de usuarios con mayor numero de post (mensajes) cambiando "user_post" por "user_reputation" pero nada:


<?php

if (!defined('IN_PHPBB'))
{
exit;
}



$sql = 'SELECT user_id, username, user_reputation, user_colour
FROM ' . USERS_TABLE . '
WHERE user_type <> ' . USER_IGNORE . '
AND user_reputation <> 0
ORDER BY user_reputation DESC';
$result = $db->sql_query_limit($sql, $config['portal_max_most_poster']);

while( ($row = $db->sql_fetchrow($result)) && ($row['username']) )
{
$template->assign_block_vars('top_poster', array(
'S_SEARCH_ACTION'=> append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $row['user_id'] . '&amp;sr=posts'),
'USERNAME' => censor_text($row['username']),
'USERNAME_COLOR'=> ($row['user_colour']) ? ' style="color:#' . $row['user_colour'] .'"' : '',
'U_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u=' . $row['user_id']),
'USER_REPUTATION' => $row['user_reputation'],
)
);
}
$db->sql_freeresult($result);

$template->assign_vars(array(
'S_DISPLAY_TOP_POSTERS' => true
));

?>



Edited 1 time(s). Last edit at 10/08/2011 06:29AM by Carles Garcia.

Options: ReplyQuote


Subject
Views
Written By
Posted
Como hacer uan consulta a mysql
3201
October 08, 2011 06:26AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.