Location: PHPKode > projects > GolfstatsPHP > golfstatsphp_3.0/menu.php
<?

//include connection script

include("dbasecon.inc.php");



//ensure that submitlogin variable really came from a form

if (isset($HTTP_POST_VARS['submitlogin'])) {

include("auth.inc.php");

} else {

include("session.inc.php");



}//endif isset submitlogin



include ("header.php");



###showtime!!!#############3

#################################RANDOM RAMBLE CODE############################
//first check if there's a deletion in the msg board
if ($delmsg=='y') {

//check once more if msguserid is for real with the id
$msgsql="Select *,ID as msgid from msgboard where ID='$msgid'";
$msgquery=mysql_query($msgsql);
$msgexist=mysql_numrows($msgquery);
if ($msgexist) {
$msgrow=mysql_fetch_array($msgquery);
				
extract($msgrow);

								 if ($userid==$login_id) {
								 $delmsg="Delete from msgboard where ID='$msgid'";
								 $delquery=mysql_query($delmsg);
								 $msgerror="Message Deleted.";								 
								 } else {
								 $msgerror="Quit fooling around, punk.";
								 }
} else {
$msgerror="Quit screwing around, punk.";
}//endif msgexist



}//endif delmsg=y


########################END RANDOM RAMBLE CODE#################################



//check if user has a game
$gamesql="Select *,date_format(date,'%d/%m/%Y') as real_date from games  
					left join courses
					ON games.courseid = courses.courseid
					order by gross_score, net_score desc
					LIMIT 5 ";

				$gamequery=mysql_query($gamesql);
				$gamerow=mysql_fetch_array($gamequery);
				$gameexist=mysql_numrows($gamequery);

?>
<STYLE TYPE="text/css">
TABLE   { border-collapse: collapse }
TR#row1 { border-top: 3px solid blue }
TR#row2 { border-top: 1px solid black }
TR#row3 { border-top: 1px solid black }
</style>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">



<? showheader("Main Menu"); ?>

<!----------------------Start of TOP TABLE------------------------------------>

<table width="100%" border=1>

<tr>
<td>

<!-------------------TOP 5 SCORES CODE---------------------------------------->
<table width="100%" border=1>
<tr class=bg1><td colspan=7><b>Top 5 Scores</td></tr>
<tr class="menu-bg"><td>&nbsp;</td><td>Player</td><td>Gross</td><td>Net</td><td>Course</td><td>Date</td></tr>
<?
$countno=1;
//OK, populate the drop down on the row.

if ($gameexist) {
do {

extract($gamerow);

//find his real name
$namesql="Select * from users_tour where userid='$userid'";

				$namequery=mysql_query($namesql);
				$namerow=mysql_fetch_array($namequery);
				$nameexist=mysql_numrows($namequery);
				
$fullname=$namerow['name']." ".$namerow['surname'];


echo "<tr class=bg4><td align='center'>$countno</td><td><a href='players2.php?userid=$userid&action=details&fullname=$fullname'>$fullname</a></td><td>$gross_score</td><td>$net_score</td>";
echo "<td><a href='statscourse2.php?courseid=$courseid&action=view'>$coursename</a></td><td>$real_date</td>"; 


echo "</tr>";

$countno++;																																								 
																																															
} while ($gamerow=mysql_fetch_array($gamequery));

} else {

echo "<tr><td colspan=6>No players defined</td></tr>";

}//endif gamerow exist
//those with gn_ is with gross and net value, so format table accordingly
?>
</table>

<!----------END OF TOP 5 SCORES CODE-------------------------------------->


</td>

<!-----------------ADDITIONAL STATS CODE---------------------->
<td width="50%">
<form method="post" action="<?=$PHP_SELF?>">


<table width="100%" border=1>
<tr class="bg1"><td colspan=5><b>Additional Stats: &nbsp; 
</b>

<select name="top5">
<option value="ddistance"> Select Top 5... </option>
<option value="ddistance" <?if ($top5=='ddistance') {echo 'SELECTED';}?>>Drive Distance (<? echo $measure; ?>)</option>
<option value="dlongest" <?if ($top5=='dlongest') {echo 'SELECTED';}?>>Longest Drive (<? echo $measure; ?>)</option>
<option value="pctdaccuracy" <?if ($top5=='pctdaccuracy') {echo 'SELECTED';}?>>Fairways Hit </option>
<option value="pctgirpct" <?if ($top5=='pctgirpct') {echo 'SELECTED';}?>>GIR</option>
<option value="pctsandsavepct" <?if ($top5=='pctsandsavepct') {echo 'SELECTED';}?>>Sand Save </option>
<option value="puttavg" <?if ($top5=='puttavg') {echo 'SELECTED';}?>>Putts/Hole</option>
<option value="puttround" <?if ($top5=='puttround') {echo 'SELECTED';}?>>Putts/Round</option>
<option value="gn_birdieavg" <?if ($top5=='gn_birdieavg') {echo 'SELECTED';}?>>Avg Birdies/round</option>
<option value="gn_paravg" <?if ($top5=='gn_paravg') {echo 'SELECTED';}?>>Avg Pars/round</option>
<option value="gn_avgscore" <?if ($top5=='gn_avgscore') {echo 'SELECTED';}?>>Avg Score</option>
<option value="gnpparbreakers" <?if ($top5=='gnpparbreakers') {echo 'SELECTED';}?>>Parbreakers</option>
<option value="gnppar3birdies" <?if ($top5=='gnppar3birdies') {echo 'SELECTED';}?>>Par3 birdies</option>
<option value="gnppar4birdies" <?if ($top5=='gnppar4birdies') {echo 'SELECTED';}?>>Par4 birdies</option>
<option value="gnppar5birdies" <?if ($top5=='gnppar5birdies') {echo 'SELECTED';}?>>Par5 birdies </option>
<option value="gnppar3pars" <?if ($top5=='gnppar3pars') {echo 'SELECTED';}?>>Par3 Pars</option>
<option value="gnppar4pars" <?if ($top5=='gnppar4pars') {echo 'SELECTED';}?>>Par4 Pars</option>
<option value="gnppar5pars" <?if ($top5=='gnppar5pars') {echo 'SELECTED';}?>>Par5 Pars</option>
<option value="gn_par3perf" <?if ($top5=='gn_par3perf') {echo 'SELECTED';}?>>Par3 Avg</option>
<option value="gn_par4perf" <?if ($top5=='gn_par4perf') {echo 'SELECTED';}?>>Par4 Avg</option>
<option value="gn_par5perf" <?if ($top5=='gn_par5perf') {echo 'SELECTED';}?>>Par5 Avg</option>
<option value="gnpscrambling" <?if ($top5=='gnpscrambling') {echo 'SELECTED';}?>>Scrambling</option>

</select>
<input type="Submit" name="statssel" value="Go>>">
</form>

</td></tr>


<?
if ($HTTP_POST_VARS['top5']) {


if (($top5=="puttavg") || ($top5=="puttround") || ($top5=="gn_avgscore") || ($top5=="gn_par3perf")
||($top5=="gn_par4perf")||($top5=="gn_par5perf")) {

$seq="ASC";
} else {
$seq="DESC";
} //endif seq


//ok if there are players only work!
if ($gameexist) {


//ok, lets format the gn stats!
if ((substr($top5,0,3) == "gn_") || (substr($top5,0,3) == "gnp"))  {

//get rid of the gn
$newtop5=substr($top5,3);
$netscore=net_.$newtop5;

//make % sign for all starting with gnp
if (substr($top5,0,3) == "gnp") { $pct="%"; } else {$pct="";} 

echo "<tr class='menu-bg'><td>&nbsp;<td>Name</td><td>Login</td><td>Gross</td><td>Net</td></tr>";

$ranksql="Select ranking.userid as userid2,name as name2,surname as surname2,login,$newtop5,$netscore 
					from ranking left join users_tour on ranking.userid=users_tour.userid 
					order by $newtop5 $seq, $netscore $seq limit 5";
			$rankquery=mysql_query($ranksql);
				$rankrow=mysql_fetch_array($rankquery);
				$rankexist=mysql_numrows($rankquery);

$countno=0;
do {
extract($rankrow);
$fullname2=$name2." ".$surname2;
$countno++;
echo "<tr class=bg4><td>$countno</td><td><a href='players2.php?userid=$userid2&action=details&fullname=$fullname2'>$fullname2</a></td><td>$login</td><td>${$newtop5} $pct</td><td>${$netscore} $pct</td></tr>";

} while ($rankrow=mysql_fetch_array($rankquery));	

} else {

//ok, lets format the gn stats!
if (substr($top5,0,3) == "pct") { 

$pct1="%";
$top5=substr($top5,3);

 } else {$pct1="";} 

echo "<tr class='menu-bg'><td>&nbsp;<td>Name</td><td>Login</td><td>Value</td></tr>";



$ranksql="Select ranking.userid as userid2,name as name2,surname as surname2,login,$top5 
					from ranking left join users_tour on ranking.userid=users_tour.userid 
					where $top5<>'0'  
					order by $top5 $seq limit 5";
			$rankquery=mysql_query($ranksql);
				$rankrow=mysql_fetch_array($rankquery);
				$rankexist=mysql_numrows($rankquery);

				
$countno=0;
do {
extract($rankrow);
$fullname2=$name2." ".$surname2;
$countno++;
echo "<tr class=bg4><td>$countno</td><td><a href='players2.php?userid=$userid2&action=details&fullname=$fullname2'>$fullname2</a></td><td>$login</td><td>${$top5} $pct1</td></tr>";

} while ($rankrow=mysql_fetch_array($rankquery));	



}//endif top5 is gn



} else {


echo "<tr><td>No Players defined</td></tr>";

} //endif gamerow



} else {
$top5="gn_avgscore";

}//endif http_post_vars



?>

</tr>

</table>

<!---------------END OF ADDITIONAL STATS---------------------------------->

</td>
</tr>
</table> 


<!----------END OF TOP TABLE---------------------------------------------->
<p>


<?

#############END of part 1###############################################





####PART 2#####################################################

//do the actions

if ($HTTP_GET_VARS['action']) {

//1.if delete
if ($action=="delete") {

///check
$checksql="Select * from gameorg where userid='$login_id' and id='$gameorgid'";
$checkquery=mysql_query($checksql);
$checkexist=mysql_numrows($checkquery);

if ($checkexist) {
$delgame="Delete from gameorg where id='$gameorgid'";
$delquery=mysql_query($delgame);

$orgerror="Game has been deleted.";

} else {

$orgerror="Trying to delete a game you did not create. Your ID has been sent to the administrative staff.";
}

}//endif action delete




if ($HTTP_GET_VARS['action']=="Join") {

//a flag to check if this user already joined, to handle the bug where user joins multiple times by refreshing page
$alreadyjoined=0;

$checksql="Select * from gameorg where id='$gameorgid'";
$checkquery=mysql_query($checksql);
	$checkrow=mysql_fetch_array($checkquery);
			
$checkexist=mysql_numrows($checkquery);

//I put a cap here at 16 players. You can easily extend the number of players here by adding checkrows

$noplayers=$checkrow['noplayers'];
$player1=$checkrow['player1'];
$player2=$checkrow['player2'];
$player3=$checkrow['player3'];
$player4=$checkrow['player4'];
$player5=$checkrow['player5'];
$player6=$checkrow['player6'];
$player7=$checkrow['player7'];
$player8=$checkrow['player8'];
$player9=$checkrow['player9'];
$player10=$checkrow['player10'];
$player11=$checkrow['player11'];
$player12=$checkrow['player12'];
$player13=$checkrow['player13'];
$player14=$checkrow['player14'];
$player15=$checkrow['player15'];
$player16=$checkrow['player16'];
//get no of slots available
$noslots=$noplayers-1;

//check slots taken
$taken=0;
for ($i = 1; $i <= "$noplayers"; $i++) {

$playercur=player.$i;   
if (${$playercur}) {
$taken=$taken+1;

//check if user already joined.
if ((${$playercur}) == "$login_id") {
$alreadyjoined=1;
}

}//endif playercur		
}///end for

if ($alreadyjoined<>1) {
	 if ($taken <= $noslots) {
	 $firstempty=$taken+1;


	 $updatesql="UPDATE gameorg SET player$firstempty= '$login_id', filled=$taken WHERE ID='$gameorgid'";
	 $updatequery=mysql_query($updatesql);

	 $orgerror="You have joined the game.";

	 } else {
	 $orgerror="Game is full. Cannot join.";
	 }//endif taken<=noslots
} //endif alreadyjoined<>1

} //endif join

////////////////REMOVE

if ($HTTP_GET_VARS['action']=="Remove") {
//to check that player don't delete others if he's no longer on the list when he refreshes page
$alreadyjoined=0;

$checksql="Select filled,player1,player2,player3,player4,player5,player6,player7
							,player8,player9,player10,player11,player12,player13,player14,player15,player16  
							 from gameorg where id='$gameorgid'";
$checkquery=mysql_query($checksql);
	$checkrow=mysql_fetch_array($checkquery);
	$checkexist=mysql_numrows($checkquery);

$filled1=$checkrow['filled'];
$player1=$checkrow['player1'];
$player2=$checkrow['player2'];
$player3=$checkrow['player3'];
$player4=$checkrow['player4'];
$player5=$checkrow['player5'];
$player6=$checkrow['player6'];
$player7=$checkrow['player7'];
$player8=$checkrow['player8'];
$player9=$checkrow['player9'];
$player10=$checkrow['player10'];
$player11=$checkrow['player11'];
$player12=$checkrow['player12'];
$player13=$checkrow['player13'];
$player14=$checkrow['player14'];
$player15=$checkrow['player15'];
$player16=$checkrow['player16'];


for ($i = 0; $i <= 15; $i++) {

$curplayer=$checkrow[$i];

if ($curplayer=="$login_id") {
$count=$i;
$playerpos="player$count";
$alreadyjoined=1;
} else {}//endif

}///end for
//echo ${$playerpos};

if ($alreadyjoined==1) {

$newfilled1=$filled1-1;

$removeme="UPDATE gameorg SET $playerpos= '', filled=$newfilled1 WHERE ID='$gameorgid'";
$removequery=mysql_query($removeme);


//now finally shift everything right of former player to the left one
for ($i = $count; $i <= 16; $i++) {
$count2=$i+1;
$playerpos="player$i";
$playerpos2="player$count2";
$shiftme="UPDATE gameorg SET $playerpos= '${$playerpos2}' WHERE ID='$gameorgid'";
$shiftmequery=mysql_query($shiftme);

} //endfor

$orgerror="You are removed from the game.";

} //endif alreadyjoined

} //endif remove






##################END REMOVE

} //endif getvars action

//get game organisation!
$gameorgsql="Select *,gameorg.id as gameorgid,date_format(gameorg.date,'%d/%m/%Y') as real_date  
						from gameorg left join users_tour on gameorg.userid=users_tour.userid 
						left join courses on gameorg.courseid = courses.courseid 
						 ORDER BY date DESC LIMIT 10";

				$gameorgquery=mysql_query($gameorgsql);
				$gameorgrow=mysql_fetch_array($gameorgquery);
				$gameorgexist=mysql_numrows($gameorgquery);
				




?>
<? echo "<font class='error'>$orgerror</font>"; ?>
</table>
<p>

<table width="100%" border=1>
<tr>
<td>
<tr class="menu-bg"><td colspan=9><b>Upcoming Games&nbsp;</b><a href='startgame.php'>[Click to Organise]</a></td>
</tr>
<tr class="menu-bg"><td>Event</td><td>Date</td><td>Time</td><td>Course</td><td>Submitted</td>
<td>Contact</td><td>Flight</td><td>Action</td><td>Players</td></tr>
<?
if ($gameorgexist) {
 
do {
$playerin=0;
extract($gameorgrow);
$newfilled=$filled+1;
echo "<tr><td>$eventname</td><td>$real_date</td><td>$time</td>
<td><a href='statscourse2.php?courseid=$courseid&action=view'>$courseid</a></td>
<td><a href='players2.php?userid=$userid&action=details&fullname=$name $surname'>$name $surname</a></td>
<td>$phoneno</td><td>$newfilled / $noplayers</td>";


//now check actions
if ($login_id==$userid) {
echo "<td><a href='$PHP_SELF?action=delete&gameorgid=$gameorgid'>[Del]</a>
<a href='startgame.php?action=modify&gameorgid=$gameorgid'>[Edit]</a></td>";


} else {

$checkplayersql="Select player1,player2,player3,player4,player5,player6,player7
							,player8,player9,player10,player11,player12,player13,player14,player15,player16 
							 from gameorg where id='$gameorgid'"; 

				$checkplayerquery=mysql_query($checkplayersql);
				$checkplayerrow=mysql_fetch_array($checkplayerquery);
				$checkplayerexist=mysql_numrows($checkplayerquery);
//check if the loginid is in the array
//ok, now see if login id is in this array
for ($i = 0; $i <= 11; $i++) {

$curplayer=$checkplayerrow[$i];
if ($curplayer=="$login_id") {

$playerin=$playerin+1;
} else {
$playerin=$playerin+0;
}//endif

}///end for

if ($playerin > 0) {
$actionitem="Remove";
} else {
$actionitem="Join";
}

echo "<td><a href='$PHP_SELF?action=$actionitem&gameorgid=$gameorgid'>[$actionitem]</a></td>";
}




//finally list out the guys in
$inplayersql="Select player1,player2,player3,player4,player5,player6,player7
							,player8,player9,player10,player11,player12,player13,player14,player15,player16 
							 from gameorg where id='$gameorgid'"; 

				$inplayerquery=mysql_query($inplayersql);
				$inplayerrow=mysql_fetch_array($inplayerquery);
				$inplayerexist=mysql_numrows($inplayerquery);
				
echo "<td>";
$countplayer=0;
for ($i = 0; $i <= 15; $i++) {

$curplayer=$inplayerrow[$i];

if ($curplayer<>"") {
$countplayer++;

if ($countplayer<4) {
echo "$curplayer-";
} elseif ($countplayer==4) {
echo "$curplayer<br>";
}elseif ($countplayer<8) {
echo "$curplayer-";
}elseif ($countplayer==8) {
echo "$curplayer<br>";
} elseif ($countplayer<12) {
echo "$curplayer-";
}elseif ($countplayer==12) {
echo "$curplayer<br>";
} elseif ($countplayer<16) {
echo "$curplayer-";
}elseif ($countplayer==16) {
echo "$curplayer<br>";
}

} else {};


}///end for

echo "</td>";


echo "</tr>";



}while ($gameorgrow=mysql_fetch_array($gameorgquery));

} else { 
				

echo "<tr><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td></tr>";
}






?>








</table>
</td></tr>
</table>

<!---------------END OF PART 2---------------------------------------------->




<!---------------------------PART 3------------------------------------------->

<p>
<table border=0 width=100%>
<td width=50%>
<?

//Ramblings from the TourLeader. You can change this portion to whatever you want
$mugshot="mug_"."$tourleaderid".".jpg";

?>
<table border=0 width=100%>
<tr>
<td style="vertical-align: middle;" align="center">
<img src="images/<?echo $mugshot;?>" border="1">
</td>

<td><b><u>Ramblings of the TourLeader</u></b><p>
<i>Excerpts from the ramblings of our esteemed Tour Leader</i>


</td>
</tr>
</table><p>

<table border=1>

<tr><td>
<a href="javascript:void(0);" onclick="window.open('leadramble.php?article=007','Ramble','scrollbars=yes,width=500,height=600,left=100,top=0')">
Ramble 7
</a>
</td></tr>
<tr><td>
<a href="javascript:void(0);" onclick="window.open('leadramble.php?article=006','Ramble','scrollbars=yes,width=500,height=600,left=100,top=0')">
Ramble 6
</a>
</td></tr>
<tr><td>
<a href="javascript:void(0);" onclick="window.open('leadramble.php?article=005','Ramble','scrollbars=yes,width=500,height=600,left=100,top=0')">
Ramble 5
</a>
</td></tr>
<tr><td>
<a href="javascript:void(0);" onclick="window.open('leadramble.php?article=004','Ramble','scrollbars=yes,width=500,height=600,left=100,top=0')">
Ramble 4
</a>
</td></tr>
<tr><td>
<a href="javascript:void(0);" onclick="window.open('leadramble.php?article=003','Ramble','scrollbars=yes,width=500,height=600,left=100,top=0')">
Ramble 3
</a>
</td></tr>
<tr><td>
<a href="javascript:void(0);" onclick="window.open('leadramble.php?article=002','Ramble','scrollbars=yes,width=500,height=600,left=100,top=0')">
Ramble 2
</a>
</td></tr>

<tr><td>
<a href="javascript:void(0);" onclick="window.open('leadramble.php?article=001','Ramble','scrollbars=yes,width=500,height=600,left=100,top=0')">
Ramble 1
</a>
</td></tr>


</table>


<p>
<?
###################This part is for tour money leaders and rank points###############


//get players first
//$ranksql="Select ranking.userid as userid2,name as name2,surname as surname2,login,total_money,total_points 
	//				from ranking left join users_tour on ranking.userid=users_tour.userid 
		//			order by total_money DESC ";
					
$ranksql="Select ranking.userid as userid2,users_tour.name as name2,users_tour.surname as surname2,
users_tour.login,ranking.total_money,ranking.total_points, count(games.userid) as no_tourney 
from ranking left join users_tour 
on ranking.userid=users_tour.userid
left join games on ranking.userid=games.userid
and games.tournament=1 
group by games.userid 
order by total_money DESC, no_tourney ASC";
					
			$rankquery=mysql_query($ranksql);
				$rankrow=mysql_fetch_array($rankquery);
				$rankexist=mysql_numrows($rankquery);

if ($rankexist) {
?>
<table width="70%" border=1>
<tr class=bg1><td colspan=7><b>Money Leaders and Ranking</td></tr>
<tr class="menu-bg"><td>&nbsp;</td><td>Player</td><td>Events</td><td>Money</td></tr>
<?
$countno=1;
//OK, populate the drop down on the row.
do {

extract($rankrow);

//get his fullname
$fullname=$rankrow['name2']." ".$rankrow['surname2'];	

echo "<tr class=bg4><td align='center'>$countno</td><td><a href='players2.php?userid=$userid2&action=details&fullname=$fullname'>$fullname</a></td><td>$no_tourney</td><td>\$$total_money</td>";


echo "</tr>";

$countno++;																																								 
																																															
} while ($rankrow=mysql_fetch_array($rankquery));

echo "</table>";

} else {


}//endif rankexist

echo "<p>";

$pointranksql="Select ranking.userid as userid2,users_tour.name as name2,users_tour.surname as surname2,
users_tour.login, ranking.total_points  
from ranking left join users_tour 
on ranking.userid=users_tour.userid
order by total_points DESC";
			$pointrankquery=mysql_query($pointranksql);
				$pointrankrow=mysql_fetch_array($pointrankquery);
				$pointrankexist=mysql_numrows($pointrankquery);


if ($pointrankexist) {
?>
<table width="70%" border=1>
<tr class=bg1><td colspan=7><b>Overall Ranking</td></tr>
<tr class="menu-bg"><td>&nbsp;</td><td>Player</td><td>Points</td></tr>
<?
$countno=1;
//OK, populate the drop down on the row.
do {

extract($pointrankrow);

//first make sure he has 2 or more games under him
$roundchecksql="select * from games where userid='$userid2'";
				$roundcheckquery=mysql_query($roundchecksql);
				$roundcheckrow=mysql_fetch_array($roundcheckquery);
				$roundcheckexist=mysql_numrows($roundcheckquery);

if ($roundcheckexist>1) {
//get his fullname
$fullname=$pointrankrow['name2']." ".$pointrankrow['surname2'];


echo "<tr class=bg4><td align='center'>$countno</td><td><a href='players2.php?userid=$userid2&action=details&fullname=$fullname'>$fullname</a></td><td>$total_points</td>";


echo "</tr>";

$countno++;																																								 
																																													
  }//endif roundcheckexist>1																																															
} while ($pointrankrow=mysql_fetch_array($pointrankquery));

echo "</table>";

} else {


}//endif rankexist






?>
<p>
<center>
<a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=108185&amp;type=2" width="125" height="37" border="0" alt="SourceForge.net Logo" /></a>
</center>

</td>


<!-------------END OF PART 3------------------------------------------------->





<!----------------------------PART 4------------------------------------------>

<td width=50%>
<?
//get the random ramble
$randomsql="Select *,date_format(date,'%d/%m/%Y') as real_date
				from msgboard where rambleid<>0 
				order by date DESC,msgtime DESC"; 
				$randomquery=mysql_query($randomsql);
				$randomrow=mysql_fetch_array($randomquery);
				$randomexist=mysql_numrows($randomquery);

$randomno=rand(1,$randomexist);
//AND AGAIN
$randomsql="Select *,date_format(date,'%d/%m/%Y') as real_date
				from msgboard where rambleid=$randomno"; 
				$randomquery=mysql_query($randomsql);
				$randomrow=mysql_fetch_array($randomquery);
				$randomexist=mysql_numrows($randomquery);


?>
<table width=100%>
<tr border=1 class="menu-bg"><td colspan=2><b>Random Ramble&nbsp;</b></td>
</tr>
<?
if ($randomexist) {				
//lets get a random number for randomid
extract($randomrow);
$mugshot="mug_$userid".".jpg";
echo "<TR><td align=center style='vertical-align:middle;'><img src='images/$mugshot' border=1><br><b>$userid</b></td>";
echo "<td width=80%>$message</td></tr>";
}
?>
</table>
<p>

<table border=1 width=100%>
<tr class="menu-bg"><td><b>Message Board&nbsp;</b><a href='addmessage.php'>[Add Message]</a></td>
</tr>
<tr class="menu-bg2"><td>
<b>10 most recent messages</b><br>
<?
echo $msgerror."<p>";
$msgsql="Select *,date_format(date,'%d/%m/%Y') as real_date
				from msgboard where rambleid=0 
				order by date DESC,msgtime DESC  
				LIMIT 10"; 
				$msgquery=mysql_query($msgsql);
				$msgrow=mysql_fetch_array($msgquery);
				$msgexist=mysql_numrows($msgquery);
if ($msgexist) {				
do {
extract($msgrow);
echo "<p>$message";
//add an option here to delete
if ($userid==$login_id) {
echo "&nbsp;&nbsp;<a href='$PHP_SELF?delmsg=y&msguserid=$userid&msgid=$ID'>[Delete Message]</a>";
}

echo "<br>";

echo "--<b>$userid (at $msgtime on $real_date)</b>";


} while ($msgrow=mysql_fetch_array($msgquery)); 				
} else {};				
?>

<?
$mug_edward_shot="mug_"."edward".".jpg";
$mug_chris_shot="mug_"."chris".".jpg";
?>
</td></tr>
</table>


<!---------------END OF PART 4-------------------------------------------->



<p>










<!------PART 5------------------------------------------------------------>

<table border=1 width=100%>
<tr>
<td style="vertical-align: middle;" colspan=3>
<p class=bg1>Files Dump</p>

</td>
</tr>
<tr  class=bg4>
<td><b>Description</td><td><b>Download</td>
</tr>

<tr>
<td>The immortal Collage of Hackers version 1</td><td><a href="files/THCollage.jpg">THCollage.jpg</a></td>
</tr>
<tr>
<td>Complete List of Players version 1, along with Eugene's (un)professional reviews</td><td><a href="files/THList.xls">THList.xls</a></td>
</tr>


</table>


<!------------End OF PART 5---------------------------->


</td>
</tr>

</table>


<? showfooter(); ?>
Return current item: GolfstatsPHP