In the following code i'm using If/else statement to display games played by the user. But the php code somewhere is wrong but i'm not able to figure it out, so far the logic according to me is right. The code explains that if the user has not played any games it should show the message as "you have not played any games please goto the link to play games.<a href="">Games</a>"
The problem is in the if/else statement, Even if the user has played any games its still showing that you have not played any games.
here is the code :
<?php
session_start();
include_once("includes/checksession.php");
include_once("includes/appconfig.inc.php");
include_once("common/meta.php");
require_once("includes/mysql.inc.php");
include_once("classes/dbconn.class.php");
include_once("classes/games.class.php");
$prefix = "p";
$uid = $_session['uid'];
$games = new Games;
?>
<body>
<div >
<!----------------------H-E-A-D-E-R---------------------->
<?php include("common/maintop.php"); ?>
<!----------------------H-E-A-D-E-R---------------------->
<!----------------------M-E-N-U---------------------->
<?php include("common/topnav3.php"); ?>
<?php include("common/topsubnav.php"); ?>
<!----------------------M-E-N-U---------------------->
<div id="long">
<!----------------------M-A-I-N-B-O-D-Y---------------------->
<!--UPPER-->
<div class="main_p">
<!--Sidebar-->
<?php
if(isset($_SESSION['uid'])){
include("common/rightnavloggedin.php");
}else{
include("common/rightnav.php");
}
$flipper = 0;
$dice = 0;
$arrGamescount = $games->myGamesCount($prefix, $uid);
if(count($arrGamescount)>0)
{
foreach($arrGamescount as $rows)
{
if($rows['game_id'] == 1 || $rows['game_id'] == 2 || $rows['game_id'] == 3)
{
$flipper++;
}
if($rows['game_id'] == 4 || $rows['game_id'] == 5 || $rows['game_id'] == 6)
{
$dice++;
}
}
}
if($flipper > $dice)
{
$game1 = "<div id=\"game_thumb\"><div id=\"game_name\">Flipper Challenge</div>
<a href=\"games/Flipper-Challenge/main/Intro.html\" onClick=\"return flipperpopup(this, 'Flipper-Challenge')\"><img src=\"images/thumbs/flipper.jpg\"></a></div>";
$game2 = "<div id=\"game_thumb\"><div id=\"game_name\">7 Up-Down: Dice Duel</div>
<a href=\"games/7-Up-Down-Dice-Duel/main\" onClick=\"return dicepopup(this, '7-Up-Down-Dice-Duel')\"><img src=\"images/thumbs/7-up-down-dice-duel.jpg\"></a></div>";
}
else
{
$game1 = "<div id=\"game_thumb\"><div id=\"game_name\">7 Up-Down: Dice Duel</div>
<a href=\"games/7-Up-Down-Dice-Duel/main\" onClick=\"return dicepopup(this, '7-Up-Down-Dice-Duel')\"><img src=\"images/thumbs/7-up-down-dice-duel.jpg\"></a></div>";
$game2 = "<div id=\"game_thumb\"><div id=\"game_name\">Flipper Challenge</div>
<a href=\"games/Flipper-Challenge/main/Intro.html\" onClick=\"return flipperpopup(this, 'Flipper-Challenge')\"><img src=\"images/thumbs/flipper.jpg\"></a></div>";
}
?>
<!--Sidebar-->
<!--Gellery-->
<div id="box">
<div id="games_outer_case">
<?php
if($flipper>0)
{
echo $game1;
}
elseif($dice>0)
{
echo $game2;
}
else
{
echo "<div >You din't play any games yet click on the link below to visit our games page</div>"."<br>";
echo '<a href="http://www.funterr.com/games.php">Games</a>';
}
?>
</div>
</div>
?>