我想要实现的是将已经完成的SQL表查询链接到另一个SQL表查询。因此,为了提供更多信息,我们需要为我的学校作业制作游戏。我正在做一个小口袋妖怪的战斗游戏。我查询了我的SQL表,它给了我目前在表中所有的Pokemon_Type。我希望用户能够单击正在显示的表条目,然后再次查询数据库,显示该类型的信息。 Here is the webpage in question.不要判断我的HTML技能xD。所以你可以看到atm有电动'输入,我希望能够点击它并刷新页面并显示与SQL表中该类型相关联的所有Pokemon。这可能吗?如果是这样的话?
如果你想看到它,我的代码到目前为止。
<!DOCTYPE html>
<html>
<head>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px
}
</style>
<title>Pokemon Fight!</title>
<center>Pokemon Fight!</center>
</head>
<body>
Select your type!
<?php
require_once('../mysqli_connect.php');
$query = "SELECT pokemon_type FROM pokemon";
$response = @mysqli_query($dbc, $query);
if($response){
echo '<table align="left"
cellspacing="5" cellpadding="8">
<tr><td align="left"><b>Pokemon Type</b></td></tr>';
while($row = mysqli_fetch_array($response)){
echo '<tr><td align="left">' .
$row['pokemon_type'] . '</td><td align="left"></td>';
echo '</tr>';
}
echo '</table>';
} else {
echo "Couldn't issue database query<br />";
echo mysqli_error($dbc);
}
mysqli_close($dbc);
?>
</body>
</html>
答案 0 :(得分:1)
最简单的方法是创建一个链接到您的口袋妖怪类型标签到另一个页面传递您的类型ID通过href。 看看这篇文章,关于你想做什么:PHP passing variable id through href
但是使用ajax可以更好地动态加载信息而无需重新加载页面