Vote for president!

Mods, snippets and styles postet and supported by the users
Forum rules
As the forum title says this is for User Contributions
Post a support request in this forum and you will be banned!
Locked
User avatar
Solidjeuh
BBCoder IV
BBCoder IV
Posts: 257
Joined: 16 Oct 2011, 02:15
BBCodes: 7
Favourite MOD: Top stats
Location: Aalst / Belgium
Contact:

Vote for president!

Post by Solidjeuh »

This is the 'Vote for president' snippet.
This is not mine! I grabbed part of the code from the Board3 portal random member module.

------------------------------------------

open index.php

Find:

Code: Select all

// Assign index specific vars
Add before:

Code: Select all

		switch ($db->sql_layer)
		{
			case 'postgres':
			$sql = 'SELECT *
				FROM ' . USERS_TABLE . '
				WHERE user_type <> ' . USER_IGNORE . '
				AND user_type <> ' . USER_INACTIVE . '
				ORDER BY RANDOM()';
			break;

			case 'mssql':
			case 'mssql_odbc':
			$sql = 'SELECT *
				FROM ' . USERS_TABLE . '
				WHERE user_type <> ' . USER_IGNORE . '
				AND user_type <> ' . USER_INACTIVE . '
				ORDER BY NEWID()';
			break;

			default:
			$sql = 'SELECT *
				FROM ' . USERS_TABLE . '
				WHERE user_type <> ' . USER_IGNORE . '
				AND user_type <> ' . USER_INACTIVE . '
				ORDER BY RAND()';
			break;
		}

		$result = $db->sql_query_limit($sql, 1);
		$row = $db->sql_fetchrow($result);

        $username = $row['username'];
		$user_id = (int) $row['user_id'];
		$colour = $row['user_colour'];

		$template->assign_block_vars('random_member', array(
			'USERNAME_FULL'		=> get_username_string('full', $user_id, $username, $colour),
			'USERNAME'			=> get_username_string('username', $user_id, $username, $colour),
			'USER_COLOR'		=> get_username_string('colour', $user_id, $username, $colour),
		));
		$db->sql_freeresult($result);
Open: /styles/prosilver/template/index_body.html

Place wherever you want it ti show:

Code: Select all

<!-- BEGIN random_member -->
<p>Vote <span style="font-weight:bold; ">{random_member.USERNAME_FULL}</span> for President!</p>
<!-- END random_member -->
Screenshot:
2014-12-24 00 43 09.png
Last edited by Solidjeuh on 24 Dec 2014, 01:43, edited 2 times in total.
Wij promoten UW muziek in ons forum & delen alles via Sociale media!
Mail uw single + hoesje + info naar: info@muziekpromo.net of Solidjeuh@textradio.be
===============
Onze Website: https://www.muziekpromo.net
User avatar
martin123456
BBCoder VI
BBCoder VI
Posts: 765
Joined: 25 Jul 2011, 13:29
BBCodes: 34
Favourite MOD: Ban button
Location: Down south!
Contact:

Vote for president!

Post by martin123456 »

User avatar
Solidjeuh
BBCoder IV
BBCoder IV
Posts: 257
Joined: 16 Oct 2011, 02:15
BBCodes: 7
Favourite MOD: Top stats
Location: Aalst / Belgium
Contact:

Vote for president!

Post by Solidjeuh »

martin123456 wrote:You mean this one ? viewtopic.php?f=40&t=1977&p=12679&hilit=+vote#p12679
I tried that one.. Not working on my forum..
This code is a little different, and it works.. :roll:
This one also grabs the color of the group the user is in.. :D
Wij promoten UW muziek in ons forum & delen alles via Sociale media!
Mail uw single + hoesje + info naar: info@muziekpromo.net of Solidjeuh@textradio.be
===============
Onze Website: https://www.muziekpromo.net
User avatar
Stoker
Site Admin
Site Admin
Posts: 3521
Joined: 12 May 2008, 23:26
BBCodes: 239
Favourite BBCode: Anipro
Favourite MOD: PrettyPhoto
Location: Denmark
Contact:

Vote for president!

Post by Stoker »

Code works perfect, its what I use here.
BTW, my code is also from the b3 portal random member :D
Board rules! No PM support
User avatar
Steve
BBCoder VI
BBCoder VI
Posts: 803
Joined: 05 Mar 2010, 01:10
Extra Rank: Donator.png
BBCodes: 2000
Favourite BBCode: porn tube
Favourite MOD: Non of Stokers
Location: up your bum
Contact:

Vote for president!

Post by Steve »

No need to use a switch for database types just also use $db->build_sql_query()
NAPWR wrote: Nice, Stoker is Hot
User avatar
RMcGirr83
BBCoder III
BBCoder III
Posts: 104
Joined: 08 Mar 2010, 13:17
Favourite MOD: mChat
Contact:

Vote for president!

Post by RMcGirr83 »

That switch is needed for the different databases RANDOM function which ever it may be. (ORDER BY RANDOM()';ORDER BY NEWID()';ORDER BY RAND()';)
User avatar
Mindful Person
BBCoder I
BBCoder I
Posts: 2
Joined: 25 Jul 2014, 23:40
BBCodes: 16

Vote for president!

Post by Mindful Person »

Can this code show only members from a specific group?
User avatar
martin123456
BBCoder VI
BBCoder VI
Posts: 765
Joined: 25 Jul 2011, 13:29
BBCodes: 34
Favourite MOD: Ban button
Location: Down south!
Contact:

Vote for president!

Post by martin123456 »

Mindful Person wrote:Can this code show only members from a specific group?

viewtopic.php?f=40&t=1977&p=12679&hilit=+vote#p12679
User avatar
Mindful Person
BBCoder I
BBCoder I
Posts: 2
Joined: 25 Jul 2014, 23:40
BBCodes: 16

Vote for president!

Post by Mindful Person »

I dont need it anymore.
Thanks anyway Martin I have found the solution.
Locked