Hi using the code below i generate a table with a submit button for each row
function GetPlayer($link){
if (isset($_SESSION['username'])) {
$x = 0;
$sql = "SELECT * FROM userstats ORDER BY RAND() LIMIT 5; ";
$result = mysqli_query($link,$sql);
while($row = mysqli_fetch_assoc($result)){
if($row['username'] !== $_SESSION['username']){//add so it dosent put duplicates
echo ("<tr>");
echo ("<th>".$row['username']." </th>");
echo ("<th>Level: ".$row['Level']." </th>");
echo ("<th>Player Stats:".$row['Attack']."/".$row['Defence']." </th>");
echo ("<th>Win Chance: ");
echo CalculateWinChance($link,$row['Defence']);
echo ("<th><input type ='submit' name = 'Attack_Btn' value ='Attack'></th>");
echo ("</tr>");
}
}
}
}
now i need this button to call 2 functions and passing in certain values to these functions
an example of a button that is not generated this way but does use the same functions is below
if(isset($_POST['Dummy_Btn'])){
$winChance = CalculateWinChance($link,5);
Train($link,1,1,$winChance);
}
is calls two functions passing in 5 to return a different value that then gets passed into another function
how am i able to get the data such as $row['Attack'] and it be different from each of the other generated submit buttons.
ive been reading about ajax could this be used in this situation?
<button type="submit" value="100">Attack</button>. Ajax would only be useful if you are trying to load/process data without wanting to reload the whole page.