我想在数组中存储三个变量值。这些是HomeResult,Draw和AwayResult。我想在另一个php文件中使用它。在图像中你可以看到最终的网站。问题是我可以获得团队的名称以及行的值,但结果不成功。
或者是否有其他方法可以实现这一目标?
我不确定是否使用包含php的B,E,F和O变量。 最终网站代码;
<table class="table">
<thead>
<tr>
<th>Home Team</th>
<th>Away Team</th>
<th>Result</th>
<th>B</th>
<th>E</th>
<th>F</th>
<th>O</th>
</tr>
</thead>
<tbody>
<?php
include 'ff.php';
include 'result.php';
foreach ($champs as $champ ) :
?>
<tr>
<td><?php echo $champ['HOME'];?></td>
<td><?php echo $champ['AWAY'];?></td>
<td></td>
<td><?php echo $champ['B'];?></td>
<td><?php echo $champ['E'];?></td>
<td><?php echo $champ['F'];?></td>
<td><?php echo $champ['O'];?></td>
</tr>
<?php
endforeach;
?>
file result.php
include 'champs.php';
$HomeWins=0;
$Draw=0;
$AwayWins=0;
foreach ($champs as $champ ) :
$B =$champ['B'];
$E=$champ['E'];
$F=$champ['F'];
$O=$champ['O'];
$sql = "SELECT * FROM England where B = '$B' AND E = '$E' AND F = '$F' AND O ='$O' ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
$rowcount=mysqli_num_rows($result);
// output data of each row
while($row = $result->fetch_assoc()) {
if($row['Q'] == 1){
$HomeWins++;
}
elseif($row['Q'] == 0){
$Draw++;
}else{
$AwayWins++;
}
}
$HomeResult =round(($HomeWins/$rowcount )*100);
$DrawResult = round(($Draw/$rowcount )*100);
$AwayResult =round( ($AwayWins/$rowcount )*100);
} else {
echo "0 results";
}
endforeach;
$conn->close();
?>