-2
各行にドロップダウンメニューと送信ボタンを含むテーブルを作成する必要があります。 ドロップダウンメニューには、SQLテーブルのアドバイザの一覧が表示されます。私が選択して顧問をして、提出ボタンを押すと、現在の行のアイテムのIDと、次に選択されたアドバイザーIDまたは名前を別のページに送信する必要があります。私の場合、それはdelete.phpに送られます。別のSQLテーブルの名前のリストを含むドロップダウンメニューを含むSQLデータベースからテーブルを作成
私のコードは、テーブルの各行にドロップダウンメニューと送信ボタンを表示しますが、送信ボタンを押すと、テーブルの下部にある送信ボタンを押すと正しく動作します。私はドロップダウンメニューから情報を送信しないように見える他のいずれかを押します。
(私のコードがわかりにくいと知っています。何か不明な点があれば私は実験しています。私に尋ねるとわかります) ありがとう!ここで
<!DOCTYPE html>
<html>
<body>
<?php
//this is he code for the qeue
// connect to the database udinh sqli
$con = get_sqli();
// get results from database
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
//select whole list of students from walk_in
mysqli_select_db($con,"login");
$sql="SELECT * FROM walk_in";
$result = mysqli_query($con,$sql);
if (!$result) {
printf("Error: %s\n", mysqli_error($con));
exit();
}
mysqli_close($con);
//Table to dispaly qeueu of students
echo "<table border='1' cellpadding='10'>";
echo "<tr> <th>ID</th> <th>First Name</th> <th>Last Name</th><th>Advisor Student wants to see</th><th>P ID</th><th>Select Advisor to notify on send</th><th>Send Student</th><th> </tr>";
echo "<tr>";
//create a table of students by displaying all the data from result and adding a button
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['FirstName'] . "</td>";
echo "<td>" . $row['LastName'] . "</td>";
echo "<td>" . $row['Advisor'] . "</td>";
echo "<td>" . $row['pid'] . "</td>";
// echo '<form action="delete.php?id2=' . $row['id'] . '" method="post">';
// drop down menu for selecting advisor as a form submission
// used to name each submit button with the id from walk_in
$formId = $row['id'] ;
echo "<td>" ;
//create a form to submit the sleected advisor and the seelcted student to be removed from the queue
echo '<form action="delete.php?id=' . $row['id'] . '" method="post">';
//another query used to retreive the list of advisors to pupulate the drop down menu
//create a drop down menu with advisors resulting from the queue
echo '<select name="formStatus">';
$con = get_sqli();
mysqli_select_db($con,"login");
$sql="SELECT * FROM login_details WHERE level = 0 AND logged = 1";
$result2 = mysqli_query($con,$sql);
if (!$result2) {
printf("Error: %s\n", mysqli_error($con));
exit();
}
//loops through all advisors for drop down menu creation
while ($row2 = mysqli_fetch_array($result2)) {
$id = $row2['id'];
echo '<option value="'.$id.'">'.$id.'</option>';
}
echo'<option selected="selected"></option>';
echo '</select>';
echo '<td><input type="submit" name="formSubmit" value= "'.$formId.'" /><td>';
//echo '<td><input type="submit" name="formSubmit" value= /><td>';
//echo '<td><a href="delete.php?id=' . $row['id'] . '&advisor='. "lol" .'">Send</a></td>';
echo "</tr>";
}
// close table>
echo "</table>";
?>
<p><a href="new.php">Add a new record</a></p>
</body>
</html>
は、私が使用していますテーブルです:
login_detailsテーブル含む顧問詳細
閉じた「」タグは表示されません。 –
javascript/jqueryに関連するコードがない場合は、迷惑メールを送信しないでください。 –
分かりやすいコードの字下げが良い考えです。コードを読むのに役立ちます。もっと重要なのは**あなたのコードをデバッグするのに役立ちます** [コーディング標準を見てください](http://www.php-fig.org/psr/psr-2/ )あなた自身の利益のために。あなたはこのコード を数週間/数ヶ月で修正するように頼まれるかもしれません。そして、あなたは私に最後に感謝します。 – RiggsFolly