Creating a war/batlle/attack thing

Alright so I have three kingdoms in my game and I want to be able to attack them. Heres what ive got in code for the page.

[code]<?php
require (“header.php”);

$kingdom = $pvar[‘ckingdom’];

$result = mysqli_query($conn, “SELECT * FROM kingdom”);
$result1 = mysqli_query($conn, “SELECT * FROM kingdom WHERE kname = ‘$kingdom’”);

echo "

";

while($row = mysqli_fetch_array($result))
{
echo “

”;
echo “”;
echo “”;
echo “”;
}
echo “
Id Kingdom Attack
” . $row[‘id’] . “” . $row[‘kname’] . “
”;
?>[/code]

What I am wanting to do is make the attack button represent the kingdom to the left. So it should essentially look like this

id Kingdom Attack
1 Barmosa Attack
2 Traviso Attack

where in the third column attack is clickable and represent the kingdom to the left only. I have no clue how to even begin to do this. Can anyone give me suggestions?

First, this: [php]

Attack[/php] should probably be ‘Action’, you may offer other values at some point, or give a list of possible actions like, Trade, Defend, or just something else in general.

You just need to add a button with the kingdoms ID and have it call a function (AJAX to a PHP route most likely.) that would pass the action and ID to fetch results from the function.

Lastly, you are using mysqli, it has prepared statements. You should be using them. There is not a single reason to drop a variable into a SQL statement in current code, but a whole lot of reasons not to.

Sponsor our Newsletter | Privacy Policy | Terms of Service