Super Trump - PHP

Asked

Viewed 151 times

0

I am making (or trying) a super trump card. I have no knowledge in programming, much less in . PHP! What I did so far was through research and videos! I ended up learning the basics and what I really "care".

I’ll paste the code:

<html>

<head>

    <title>SINGLE PLAYER</title>
    <link rel="stylesheet" type="text/css"  href="style.css" /> 

</head>

<body id="back">


<!--Menu -->

    <div id="menu">
        <ul>
            <li><a class="a1" href="#">PLAY...</a></li>
            <li><a class="a1" href="#">MY STATS</a></li>
            <li><a class="a1" href="#">EDIT MY CARDS</a></li>
            <li><a class="a1" href="#">HOW TO PLAY?</a></li>
            <li><a class="a1" href="#">ABOUT US</a></li>
        </ul>
    </div>


<!-- DataBase and game -->

<?php

include ("connect.php"); //DataBase Conection

//card Player 1

$sql = mysql_query("SELECT * FROM card");

$i = 1;

$row[1] = mysql_fetch_array($sql);  
$row[2] = mysql_fetch_array($sql);
$row[3] = mysql_fetch_array($sql);
$row[4] = mysql_fetch_array($sql);  
$row[5] = mysql_fetch_array($sql);  
$row[6] = mysql_fetch_array($sql);  
$row[7] = mysql_fetch_array($sql);  
$row[8] = mysql_fetch_array($sql);  
$row[9] = mysql_fetch_array($sql);  
$row[10] = mysql_fetch_array($sql); 
$row[11] = mysql_fetch_array($sql); 
$row[12] = mysql_fetch_array($sql); 
$row[13] = mysql_fetch_array($sql); 
$row[14] = mysql_fetch_array($sql);     
$row[15] = mysql_fetch_array($sql); 


//card Player CPU

$sql2 = mysql_query("SELECT * FROM card2");  

$b = 1; 

$row2[1] = mysql_fetch_array($sql2);    
$row2[2] = mysql_fetch_array($sql2);
$row2[3] = mysql_fetch_array($sql2);
$row2[4] = mysql_fetch_array($sql2);    
$row2[5] = mysql_fetch_array($sql2);    
$row2[6] = mysql_fetch_array($sql2);    
$row2[7] = mysql_fetch_array($sql2);    
$row2[8] = mysql_fetch_array($sql2);    
$row2[9] = mysql_fetch_array($sql2);    
$row2[10] = mysql_fetch_array($sql2);   
$row2[11] = mysql_fetch_array($sql2);   
$row2[12] = mysql_fetch_array($sql2);   
$row2[13] = mysql_fetch_array($sql2);   
$row2[14] = mysql_fetch_array($sql2);       
$row2[15] = mysql_fetch_array($sql2);        

?>

<!-- Form -->

<form method="post">

<?php

            if (isset($_POST["Submit"])){

            if(empty($_POST["game"])){

                echo "<script> alert('Select An Atribute!')</script>";

            }

            if (!empty($_POST["game"])){ 

?>

    <div id="edit-1">
            <img src="<?php echo $row[$i]["Photo"];?>" height="500" width="285">
    </div>

    <!--Show the Card-->

    <div id="edit-3">
        <img src="<?php echo $row2[$b]["Photo"];?>" height="500" width="285">
    </div>

<?php

        foreach ($_POST ["game"] as $selected) {

            $win = $selected < $row2[$b]["Ranking"]; 

                if ($win) { 

//alert winner!
                        echo "<script> alert ('Win')</script>";
                        $i++;
                        $b++;

                    } else {

//alert lose!
                        echo "<script> alert ('Lose')</script>";
                        $i++;
                        $b++;

                    }
                }
            }
        }
?>

<!-- Card 1-->

        <div id="edit-1">
            <img src="<?php echo $row[$i]["Photo"];?>" height="500" width="285">

                <input id="radio-rw" name="game[]" type="radio" value="<?php echo $row[$i]["Ranking"];?>">
                <input id="radio-tt" name="game[]" type="radio" value="<?php echo $row[$i]["Tittles"];?>">
                <input id="radio-st" name="game[]" type="radio" value="<?php echo $row[$i]["Started"];?>">
                <input id="radio-ya" name="game[]" type="radio" value="<?php echo $row[$i]["Years Active"];?>">

                <input id="submit" type="submit" name="Submit" value="Go!">
        </div>

<!-- Card 2 VIRADA-->

        <div id="edit-3">
                <img src="others/back_card.jpg" height="500" width="285">
        </div>

</form>

</body>
</html>

Well, I need to go to the next record after clicking the "GO" button. It works only once, then it "hangs" on the 2nd letter. Each "$Row" is a card, after clicking "GO", it compares to Player 2’s card and even losing or winning it goes to the next card.

  • 2

    Enjoy seeing the tour and know how the site works. To format the code select it and use the button { }

  • Managed to resolve that issue?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.