I'm a beginner in programming and would like to know how I would make my $ id = 1 , turn 2, 3 and so on. The code at the end means that it needs to compare that value and only then $id++
occurs. I know I need to insert within while
, but I'm not sure how to put it.
It would be so, every $ row would be a letter, I put 9 just to test. It is a game in the super trump style, that is, at first it will only appear 1 (one card), and the person will select his attribute, this is done through $_POST("Submit")
. After the person clicks, this attribute will compare with another attribute, where I put that attribute ( $select > 10
) as an example only. Then, $id=1
needs to become 2, so the game continues until $id=9
is reached.
Yes! It's a card game, type Super Trump know ?! The rule is very simple, because the player even winning or losing, his card has to change. What happens is that each letter, I inserted there by $row[1]
. So after doing this comparison, which is only for testing (because compare with another letter I've already managed to apply), will go to the next letter, which would be $row[2]
. And this occurs until you reach $row[9]
.
Have you understood better?
I do not want to play the whole select at once on the screen, but only one appears, and then after that button-like comparison ("Submit"), $id=2
, and so on. p>
In short, what I need is to start with 1, and as soon as I make the comparison and click the button, the next screen is 2.
include ("connect.php"); //Conexão Banco
$sql = mysql_query("SELECT * FROM card");
$id = 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);
$pic = $row[$id]["Photo"];
$rk = $row[$id]["Ranking"];
$tt = $row[$id]["Tittles"];
$st = $row[$id]["Started"];
$ya = $row[$id]["Years Active"];
if (isset($_POST["Submit"])){
if (!empty($_POST["game"])){
foreach ($_POST ["game"] as $selected) {
if ($selected > 10) {
echo "win";
}
}
}
}
Thank you in advance.