>>  Site Map >>  Forums >>  Blocks 6x

Forum module - topics in forum:



Blocks 6x - Discussions regarding PHP-Nuke Blocks.



help with randomness...

Heres the code so far. How can I get the
Code: :
/Input the team id here for the team you would like to display

$teamid = 2;
part of the script to pull a random team from the database??
Any help would be great!! Thanks in advance.


Code: :
<?php

if (eregi("block-BattleMenu.php", $_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}

global $prefix, $db, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $textcolor1, $textcolor2;


//Input the team id here for the team you would like to display

$teamid = 2;


//Module linkage
$module_name="Battles";
$integration_url="modules.php?name=$module_name";

///////////////////////////////////////////////////////////////
//Let's get everything we need from the team id inserted above
///////////////////////////////////////////////////////////////
//get team name
$query = "select * from ".$prefix."_teams where team_id = $teamid";
$queryrs = $db->sql_query($query);
$rs = $db->sql_fetchrow($queryrs);
$teamname = $rs['name'];
//get ladder id's and the records for each ladder for the team id inserted above
$query = "select * from ".$prefix."_ladderteams where team_id = $teamid";
$queryrs = $db->sql_query($query);
for($emp=0;$rs = $db->sql_fetchrow($queryrs);$emp++) {
$ladders[$emp]['ladderid']=$rs['ladder_id'];
$records[$emp]['ladderid']=$rs['ladder_id'];
$records[$emp]['wins']=$rs['wins'];
$records[$emp]['losses']=$rs['losses'];
$records[$emp]['streakwin']=$rs['streakwins'];
$records[$emp]['streakloss']=$rs['streaklosses'];
//get rank
$query1="select * from ".$prefix."_ladders where sid = ".$rs['ladder_id']."";
$queryrs1=$db->sql_query($query1);
$rs1 = $db->sql_fetchrow($queryrs1);
$sortby1 = str_replace("[", "", $rs1["standingstype"]);
$sortby = str_replace("]", "", $sortby1);
$query2="select * from ".$prefix."_ladderteams where ladder_id = ".$rs['ladder_id']." order by $sortby DESC";
$queryrs2=$db->sql_query($query2);
for($emp2=1;$rs2 = $db->sql_fetchrow($queryrs2);$emp2++) {
if ($rs2['name'] == $teamname) {
$records[$emp]['rank']=$emp2;
}
}
}
//get ladder names for the ladder id's retrieved above
$cnt=0;
foreach($ladders as $lads) {
$query = "select * from ".$prefix."_ladders where sid = ".$lads['ladderid']."";
$queryrs = $db->sql_query($query);
for($emp=0;$rs = $db->sql_fetchrow($queryrs);$emp++) {
$ladders[$cnt]['laddername']=$rs['title'];
}
$cnt++;
}


///////////////////////////////////////////////////////////////
//Now let's start our output for the block
//This is where you would want to make it how you
//want it to look
///////////////////////////////////////////////////////////////
$content .= "<center>
TeamName: <strong>".$teamname."</strong>
<br><br>
<font color='ac0f0e'><strong>Competitions:</strong></font>
<br>";
foreach($ladders as $lads) {
$content .= "<br>";
$content .= "<strong>".$lads['laddername']."</strong>";
$content .= "<br>";
foreach ($records as $recs) {
if ($recs['ladderid'] == $lads['ladderid']) {
$content .= "Rank: ".$recs['rank'];
$content .= "<br>";
$content .= "Record: ".$recs['wins']."/".$recs['losses'];
$content .= "<br>";
$content .= "Streakwins: ".$recs['streakwin'];
$content .= "<br>";
$content .= "Streaklosses: ".$recs['streakloss'];
$content .= "<br>";
}
}
}
$content .= "</center>";

?>







If no one could help the last time you posted this http://phpnuke-uk.net/modules.php?name=Forums&file=viewtopic&p=33534 then it's unlikely they'd be able to now. Confused




Attention! You are currently viewing sitemap page!
We strongly suggest to look at original content

Search from web

Valid HTML 4.01 Valid CSS