• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Bounty Hunters better querry

renancs

New Member
Joined
Jul 8, 2008
Messages
252
Reaction score
3
Hi was looking into Boundy Hunters php file, and i try to made a better sql write.

it just the old one, made by some one in forum, i d like to thx him.

and rewrite the SQL part

PHP:
<?php
$main_content .= '
	<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%>
		<TR>
			<TD style="text-align:center;"><H2>Bounty Hunters</H2></TD>
		</TR>
		<TR BGCOLOR="'.$config['site']['vdarkborder'].'">
			<TD><CENTER><FONT COLOR=WHITE SIZE=2><b>How to use...</b></FONT></CENTER></TD>
		</TR>		
		<TR BGCOLOR="'.$config['site']['darkborder'].'">
			<TD style="text-align:left;"><b>!hunt [prize],[nick]:</b> Send an offer for hunt players. Offer in Thousands(K)
			<br><i>Example: !hunt 100,Player_name
			<br> Will Pay 100K(100 000 gold Pieces) for the Player who Kills Player_name.</i></TD>
		</TR>		
</TABLE><br><br><table>		
';
$main_content .= '
        <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
            <TR BGCOLOR="#505050">
                <TD CLASS=white width=28%>
                    <center><B>Hunted by</B></center>
                </TD>
                <TD CLASS=white width=14%>
                    <center><B>Reward</B></center>
                </TD>
                <TD CLASS=white width=28%>
                    <center><B>Player hunted</B></center>
                </TD>
                <TD CLASS=white width=28%>
                    <center><B>Killed by</B></center>
                </TD>
            </TR>';
foreach($SQL->query('SELECT A.* , B.name AS hunted_by, C.name AS player_hunted, D.name AS killed_by
						FROM bounty_hunters AS A
						LEFT JOIN players AS B ON A.fp_id = B.id
						LEFT JOIN players AS C ON A.sp_id = C.id
						LEFT JOIN players AS D ON A.k_id = B.id
						ORDER BY A.added DESC') as $bounty) {
		if($num%2 == 0){$color=$config['site']['darkborder'];}else{$color=$config['site']['lightborder'];}
		if ($bounty['killed_by']){
				$killed_by = '<a href="?subtopic=characters&name='.$bounty['killed_by'].'">'.$bounty['killed_by'].'</a>';
		} else {
				$killed_by = 'still alive';
		}
		$main_content .= '
				<TR BGCOLOR="'.$color.'">
					<TD><center><b><a href="?subtopic=characters&name='.$bounty['hunted_by'].'">'.$bounty['hunted_by'].'</a></b></center></TD>
					<TD><center><b>'.$bounty['prize'].' K gp</b></center></TD>
					<TD><center><b><a href="?subtopic=characters&name='.$bounty['player_hunted'].'">'.$bounty['player_hunted'].'</a></b></center></TD>
					<TD><center><b>'.$killed_by.'</b></center></TD>
				</TR>';
		$num++;
}
if($num == 0){
        $main_content.='<TR BGCOLOR="'.$color.'"><TD colspan=4><center>Currently there are not any bounty hunter offer.</center></TD></TR>';
}
        $main_content .='</TABLE><div align="right">Copyright &copy; <a href="http://otibia.net">oTibia.net</a>.</div></table>';
?>



Hope help some one.
Cya.
 
Just ann SQL FIX:
WHERE IS
PHP:
LEFT JOIN players AS D ON A.k_id = B.id

CHANGE FOR
PHP:
LEFT JOIN players AS D ON A.k_id = D.id


hope help somebodie
=P
 
Back
Top