<?php
	$query = "SELECT p.id as pid, p.name as pname, p.rank as prank, w.id as wid, ((w.kills6/w.deaths6)+(60*w.kills6/w.time6)+(w.hit6/w.fired6)) as kd FROM weapons as w, player as p WHERE w.id=p.id AND w.time6 > 90000 AND p.time > 360000 ORDER BY kd DESC LIMIT 5";

$query2 = "SET @n:=0";
$query3 = str_replace("FROM", ", @n:=@n+1 as num FROM", $query);
$query3 = str_replace("LIMIT 5", "", $query3);
?>
