[英]Querying Radio buttons into MYSQL database
I need advice to use radio buttons in html to query into MYSQL base on the user selection. 我需要建议在html中使用单选按钮根据用户选择查询MYSQL。
The table is called "Trainers" 该表被称为“培训师”
There are Three trainers: 有三个培训师:
The user choose what trainer he/she want to setup a meeting with. 用户选择他/她想要与之建立会议的培训师。 On the MYSQL I want to show the "krillavilla" got "5" meetings with users and "Urie" got "0" meetings with users.
在MYSQL上,我希望显示“krillavilla”与用户进行“5”会议,“Urie”与用户进行“0”会议。
I research this post: How can i add radio buttons record into MySQL fields using PHP but I was trying to avoid arrays 我研究这篇文章: 如何使用PHP将单选按钮记录添加到MySQL字段中,但我试图避免使用数组
And on this post: Inserting the selection of radio buttons into MySQL 在这篇文章中: 将选择的单选按钮插入MySQL
Doesnt answer my question what I am looking for. 不回答我的问题我在寻找什么。
This is my php: 这是我的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);
?>
This is my html: 这是我的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>
This is my second form page. 这是我的第二个表单页面。 I am trying to create a GYM schedule using three form webpages where the user will:
我正在尝试使用三个表单网页创建GYM计划,用户将在其中:
Sign up a membership=> User Select the trainer=> User selected what type of membership he/she wants=> confirmation page 注册会员=>用户选择培训师=>用户选择他/她想要的会员类型=>确认页面
but for now i need help of figuring out how can i get my radio buttons data to record how many users that assign to trainer on MYSQL. 但是现在我需要帮助找出如何获取我的单选按钮数据来记录在MYSQL上分配给培训师的用户数量。
BTW I used this: 顺便说一下我用过这个:
http://www.tutorialrepublic.com/php-tutorial/php-mysql-insert-query.php http://www.tutorialrepublic.com/php-tutorial/php-mysql-insert-query.php
as my guide 作为我的向导
value="Urie"
而不是id="Urie"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.