php - Show data after selecting a value from a listbox
问题描述
I want to do this but using php and mysqli. It takes a value and show it below:
http://biblia.cartelesparafacebook.com/bibliajs/#/biblia/genesis/1
Right now Im testing this code, but I need help for achieve this. Please I going to appreciate your help.
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="/js/scripts.js"></script>
<script>
$(document).on("change", "#name", function(){
var elem = $(this),
id = elem.val();
$(".info").hide(200); /* HIDE ALL OTHER INFORMATION */
$(".info-"+id).show(200); /* SHOW THE INFO OF THE SELECTED FULL NAME */
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<?php
require 'connect_bible.php';
$sql = mysqli_query($conn, "SELECT * FROM bible_books");
?>
<select name="dynamic_data" id="name">
<?php
$i=0;
while($row = mysqli_fetch_array($sql))
{
?>
<option value="<?=$row["idbook"];?>"><?=$row["name"];?></option>
<?php $i++;
} ?>
</select>
<?php mysqli_close($conn); ?>
<?php
$info = '';
require 'connect_bible.php';
$stmt = $conn->prepare("SELECT idverse, name, chapter, verse, text
FROM bible_verses
INNER JOIN bible_books ON bible_verses.idBook = bible_books.idBook
LIMIT 30");
$stmt->execute();
$stmt->bind_result($idverse, $name, $chapter, $verse, $text);
while($stmt->fetch()){
echo '<option value="'.$idverse.'">'.$name.'</option>';
$info .= '<div class="info info-'.$idverse.'" style="display:none">
Chapter: '.$chapter.'<br>
Verse: '.$verse.'<br>
Text: '.$text.'
</div>';
}
$stmt->close();
echo '</select>';
echo $info;
?>
</body>
</html>
I just tasting this code right now, but I need help for achieve this. Please I going to appreciate your help.
解决方案
推荐阅读
- javascript - reactjs中的React Modal
- amazon-web-services - AWS Cloud Formation cfn-signal:找不到命令
- mysql - GroupBy ID,但保留多个值
- biztalk - 根据 BizTalk 中的 xml 内容按顺序传递消息
- python - 无法在 Flask 的生产服务器中启用调试模式
- powershell - Powershell在通过文件夹递归时将文件保存在原始文件夹中
- c# - 加密自定义 .config 文件 .NET
- pyspark - Databricks - 显示数据框并打印字符串
- vim - 如何让折叠 expr 在 vim 8 中与终端一起使用
- ruby - 无法从 ruby 文件中解析行