gpt4 book ai didi

php - 将变量传递到另一个页面以进行 sql 查询

转载 作者:行者123 更新时间:2023-11-29 02:52:15 25 4
gpt4 key购买 nike

我正在尝试将一个变量从一个页面传递到另一个页面,以便我可以通过获取想法在另一个页面上显示更多信息。我不太确定出了什么问题,因为我使用 bluemix,它不会显示错误,它只会给我页面 500 错误。这是我的代码:

<?php
$strsql = "select id, name, problem, urgency, technology from idea WHERE status='saved'";
if ($result = $mysqli->query($strsql)) {
// printf("<br>Select returned %d rows.\n", $result->num_rows);
} else {
//Could be many reasons, but most likely the table isn't created yet. init.php will create the table.
echo "<b>Can't query the database, did you <a href = init.php>Create the table</a> yet?</b>";
}

?>


<?php
echo "<tr>\n";
while ($property = mysqli_fetch_field($result)) {
echo '<th>' . $property->name . "</th>\n"; //the headings

}
echo "</tr>\n";

while ( $row = mysqli_fetch_row ( $result ) ) {
$idea_id= $row['id'];
echo "<tr>\n";
for($i = 0; $i < mysqli_num_fields ( $result ); $i ++) {
echo <a href ="meerinfo.php?idea= '. $idea_id .'"> '<td>' . "$row[$i]" . '</td>'</a>;
}
echo "</tr>\n";
}


$result->close();
mysqli_close();
?>

最佳答案

您的代码中有一个小错误。你的echo <a href ="...行应该是这样的,

echo '<td><a href ="meerinfo.php?idea='. $idea_id .'">' . $row[$i] . '</a></td>';

关于php - 将变量传递到另一个页面以进行 sql 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34490593/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com