ユーザの選択に基づいてMYSQLベースを照会するために、htmlのラジオボタンを使用するためのアドバイスが必要です。MYSQLデータベースにラジオボタンを照会
- krillavilla
- Novac
- Urie
ユーザーは、彼/彼女が何をしたいのトレーナーを選択:
テーブルは "トレーナー"
と呼ばれる三つのトレーナーがあります。会議をセットアップするMYSQL上では、 "krillavilla"にはユーザーとの "5"ミーティングが、 "Urie"にはユーザーとの "0"ミーティングがあります。
私はこの記事を研究: How can i add radio buttons record into MySQL fields using PHP が、私は配列
そして、この記事のを避けるためにしようとしていた。 Inserting the selection of radio buttons into MySQL
は、私が探しています何私の質問に答えdoesntの。
これは私のPHPです:
<?php
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
$link = mysqli_connect("localhost","******","******","*****");//This is the login creditial
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());//Error check for execution
}
// Escape user inputs for security
$trainers = mysqli_real_escape_string($link, $_POST['trainers']);
// attempt insert query execution
$sql = "INSERT INTO trainers (trainers) VALUES ('$trainers')";
if(mysqli_query($link, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// close connection
mysqli_close($link);
?>
これは私のhtmlです:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add Record Form</title>
</head>
<body>
<form action="test2.php" method="post">
<p>
<input type="radio" name="trainers" id="krillavilla">krillavilla
</p>
<p>
<input type="radio" name="trainers" id="Urie">Urie
</p>
<p>
<input type="radio" name="trainers" id="Novac">Novac
</p>
<input type="submit" value="Submit">
</form>
</body>us
</html>
は、これは私の第二の形式のページです。
サインアップメンバーシップを=>ユーザーがトレーナーを選択=>ユーザーは、彼/彼女は=>確認ページを望んでいる会員の種類
を選択:私は、ユーザーがします3つのフォームWebページを使用してGYMスケジュールを作成しようとしていますしかし今のところ、私は自分のラジオボタンのデータを取得してMYSQLのトレーナーに割り当てているユーザーの数を記録することができます。
の代わりに
value="Urie"
を設定する必要があり、それは作品私のガイドとしてhttp://www.tutorialrepublic.com/php-tutorial/php-mysql-insert-query.php
!!!:
はところで私はこれを使用しました。 )あなたよりも私はそれを理解することができませんでした – Kashad
ありがとう...あなたが満足している場合は、受け入れられた回答としてそれを追加してください。 –