Facebook:php $_get variable not working

Hi there all i have a problem with my php code which i have a training system for my facebook game and i am wanting to get the tid of the variable and checking to see if its being passed by the link

like this train.php?tid=1 or 6 watever

but everytime i do that its still asumming the user has clicked on 1 but they have actually clicked on link 2

like this

<a href=“train.php?tid=1”>Train Attack</a>
<a href=“train.php?tid=2”>Train Defense0</a>

When i click on Train defense its asuuming im still clicking on train attack here is my code below


$tid=$_GET['tid'];
if($tid)
{
	include("dbconnect.php");
	//
	$pl="SELECT * FROM players WHERE user='$F_user'";
	$rs=mysqli_query($con,$pl);
	if(!$rs)
	{
		echo "Error".mysqli_error($con);
	}
	else
	{
		//
		$count=$rs->num_rows;
		if($count>0)
		{
			while($data=$rs->fetch_assoc())
			{
				//
				$atk=$data['attackmen'];
				$def=$data['defenses'];
				$spy=$data['spys'];
				$u=$data['user'];
				$un=$data['Units'];
				//
			}
		}
		//
	}
	//
	include("dbconnect.php");
	$t="SELECT * FROM training WHERE tid='$tid'";
	$result=mysqli_query($con,$t);
	if(!$result)
	{
		echo "Error".mysqli_error($con);
	}
	else
	{
		//
		$count=$result->num_rows;
		if($count>0)
		{
			while($data=mysqli_fetch_assoc($result))
			{
				//
				$td=$data['tid'];
				$message1="You do not have any units to train for attacking";
				$msg2="You cant train anymore Defense Specialists";
				$msg3="You cant train any spys";
				if($td=="1")
				{
					if($un>=1)
					{
						//
						include("dbconnect.php");
						$a="update players set attackmen=attackmen+1 WHERE user='$u'";
						$b="update players set Units=Unit-1 WHERE user='$u'";
						$rs=mysqli_query($con,$a);
						$rs=mysqli_query($con,$b);
						include("dbconnect.php");
						if(!$rs)
						{
							echo "Error updating qty error".mysqli_error($con);
						}
						else
						{
							echo "You have successfully trained some attack spcialist units";
						}
						//
					}
					else
					{
						echo $message1;
					}
					
				}
				else if($td=="2")
				{
					if($un>=1)
					{
						//
						include("dbconnect.php");
						$c="update players set defenses=defenses+1 WHERE user='$u'";
						$d="update players set Units=Units-1 WHERE user='$u'";
						$rs=mysqli_query($con,$c);
						$rs=mysqli_query($con,$d);
						include("dbconnect.php");
						if(!$rs)
						{
							echo "Error updating qty error".mysqli_error($con);
						}
						else
						{
							echo "You have successfully untrained some attack spcialist units";
						}
						//
					}
					else
					{
						echo $msg2;
					}
				}
				else if($td=="3")
				{
					if($un>=1)
					{
						//
						include("dbconnect.php");
						$e="update players set spys=spys+1 WHERE user='$u'";
						$f="update players set Units=Units-1 WHERE user='$u'";
						$rs=mysqli_query($con,$e);
						$rs=mysqli_query($con,$f);
						include("dbconnect.php");
						if(!$rs)
						{
							echo "Error updating qty error".mysqli_error($con);
						}
						else
						{
							echo "You have successfully untrained some attack spcialist units";
						}
						//
					}
				}
				if($td=="4")
				{
					if($atk>=1)
					{
						//
						include("dbconnect.php");
						$g="update players set attackmen=attackmen-1 WHERE user='$u'";
						$h="update players set Units=Unit+1 WHERE user='$u'";
						$rs=mysqli_query($con,$g);
						$rs=mysqli_query($con,$h);
						include("dbconnect.php");
						if(!$rs)
						{
							echo "Error updating qty error".mysqli_error($con);
						}
						else
						{
							echo "You have successfully un-trained some attack spcialist units";
						}
						//
					}
					else
					{
						//
						echo "you have no units to untrain";
						//
					}
				}
				else if($td=="5")
				{
					if($def>=1)
					{
						//
						include("dbconnect.php");
						$i="update players set defenses=defenses-1 WHERE user='$u'";
						$j="update players set Units=Units+1 WHERE user='$u'";
						$rs=mysqli_query($con,$i);
						$rs=mysqli_query($con,$j);
						include("dbconnect.php");
						if(!$rs)
						{
							echo "Error updating qty error".mysqli_error($con);
						}
						else
						{
							echo "You have successfully untrained some defense spcialist units";
						}	
						//
					}
					else
					{
						echo "You have no spy units to untrain";
					}
					
				}
				else if($td=="6")
				{
					if($spy>=1)
					{
						//
						include("dbconnect.php");
						$k="update players set spys=spys-1 WHERE user='$u'";
						$l="update players set Units=Units+1 WHERE user='$u'";
						$rs=mysqli_query($con,$k);
						$rs=mysqli_query($con,$l);
						include("dbconnect.php");
						if(!$rs)
						{
							echo "Error updating qty error".mysqli_error($con);
						}
						else
						{
							echo "You have successfully untrained some spy spcialist units";
						}
						//
					}
					else
					{
						echo "You have no spy units to untrain";
					}
					
				}
				//
			}
		}

Not sure if facebook is causing this

You need to check if ($tid == 2) or if ($tid == 1)