Jump to content

Problem in executing If/else statement


leroy Mckenzi

Recommended Posts

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>



?>


             

Link to comment
Share on other sites

in the section where code is $rows['game_id'] == 1 || $rows['game_id'] == 2 || $rows['game_id'] == 3 ........

 

 

'game_id'1,2,3 are indicating flipper game played with Prediction , Predisclosed and Multiplayer

 

 

same follows for dice game

 

 

where 'game_id'= 4,5,6 are indicating dice game played with Prediction , Predisclosed and Multiplayer...

Link to comment
Share on other sites

 

 

I tried and it printed the array, the output that I got is this

 

 

Array ( [0] => Array ( [id] => 834 [uid] => leroy1260 [game_id] => 0 [txn] => 748915632 [combo] => [game_combo_hr] => 2011081714 [user_combo] => DD [prefix] => p [result] => [cdate] => 2011-08-17 05:13:22 [mdate] => 2011-08-17 05:13:22 ) [1] => Array ( [id] => 811 [uid] => leroy1260 [game_id] => 4 [txn] => 0 [combo] => [game_combo_hr] => 2011081015 [user_combo] => DDUDD [prefix] => p [result] => [cdate] => 2011-08-10 06:18:34 [mdate] => 2011-08-10 06:18:34 ) [2] => Array ( [id] => 813 [uid] => leroy1260 [game_id] => 4 [txn] => 0 [combo] => [game_combo_hr] => 2011081116 [user_combo] => DUU77 [prefix] => p [result] => [cdate] => 2011-08-11 06:52:11 [mdate] => 2011-08-11 06:52:11 ) )

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.