私はPHPでスキルをテストしていますが、ブートストラップライブラリを使用しています。選択ボックスでデータベースを取得する
2つのテーブルstudents
とcountries
があります。
私は国(および関連するID)を取得する選択ボックスを手に入れました。その国の学生をフォームで見たいと思っています。
実際には、私はフォームを持って、選択肢を持っていますが、一緒にやりとりする方法を見つけることができません。
お願いします。おかげ
既存で
<?php
//Access to BDD
include 'database.php';
?>
<html>
<Head>
<title>List of students</title>
<script src="bootstrap/js/bootstrap.js"></script>
<link rel="stylesheet" href="bootstrap/css/bootstrap.css">
</Head>
<body>
<!-- formulaire de recherche -->
<form class="panel-group form-horizontal" method="get" action="home.php" role="form">
<div class="panel panel-default">
<div class="panel-body">
<div class="panel-header">
<h4>Search</h4>
</div>
<div class="col-sm-3">
<!-- dropdown countries -->
<select class="form-control" id="select" name="country">
<option value="">country</option>
<?php
$sel_country = "SELECT * FROM countries";
$run_country = mysqli_query($conn,$sel_country);
while ($rows= mysqli_fetch_assoc($run_country)){
echo '<option value='.$rows['id'].'>'.$rows['brand_name'].'</option>';
}
?>
</select>
<br/>
<br/>
<button type="submit" class="btn btn-default" id="searchbtn" name="submit">Go</button>
</div>
</div>
</div>
</form>
<?php
//SQL listing all the students.
$sql = "SELECT * FROM student ORDER by student_id"; //CHOIX NON PLUS!!!
$run_sql = mysqli_query($conn, $sql);
while ($rows = mysqli_fetch_assoc($run_sql)){
echo '<div class="container">
<table class="table table-hover">
<tr>
<td><h2><a class="btn btn-info" href="detail.php?vo_id='.$rows['student_id'].'">'.$rows ['name'].'</a></h2></td>
</tr>
<tr>
<td>'.$rows ['surname'].'</td>
</tr>
<tr>
<td>'.$rows ['age'].'</td>
</tr>
<tr>
<td>'.$rows ['country'].'</td>
</tr>
</table>
</div>
<br>';
}?>
提出後、ホームページが異なる同じページにリダイレクトしますか? – Tiger
学生リストには、あなたが選んだ国のユーザーを見たいと思っていますか? – Akshay
学生名が同じページか別のページであるのを見たいですか? –