Php 通过单击“添加”按钮在模式中获取数据

Php 通过单击“添加”按钮在模式中获取数据,php,jquery,Php,Jquery,若我在href中单击id和名称为的添加按钮(如上图所示),那个么在PHP中获得$\u get这样的模式数据后,如何分配变量 模态 这是将要显示的,我不知道如何分配到数据库中保存 <span id="puthere" class="w3-large" style="text-transform: capitalize;"><b></b></span> 您可以使用: if (isset($_GET['party'])) { echo $_

若我在href中单击id和名称为的添加按钮(如上图所示),那个么在PHP中获得$\u get这样的模式数据后,如何分配变量

模态

这是将要显示的,我不知道如何分配到数据库中保存

<span id="puthere" class="w3-large" style="text-transform: capitalize;"><b></b></span>


您可以使用:
if (isset($_GET['party'])) {
    echo $_GET['party'];
}
if (isset($_GET['partytwo'])) {
    echo $_GET['partytwo'];
}
......

XAMPP和MySQL
在php文件中:

 // Initialize your variable that will catch for your form data
 $first_nameparty="";
 $middle_nameparty="";
 $last_nameparty =""; 
 // Check the form data of your request
 if (isset($_GET['Party'])) 
     $first_nameparty = $_GET['Party'];

 if (isset($_GET['Partytwo'])) 
     $middle_nameparty = $_GET['Partytwo'];

 if (isset($_GET['Party3'])) 
    $last_nameparty = $_GET['Party3'];
 // Database configuration
 $servername = "localhost";
 $username = "username";
 $password = "password";
 $dbname = "myDB";

 // Create connection
 $conn = new mysqli($servername, $username, $password, $dbname);
 // Check connection
 if ($conn->connect_error) {
     die("Connection failed: " . $conn->connect_error);
 } 

 // SQL STATEMENT (string)
 $sql = "INSERT INTO tablename (field2, fieldname2, fieldname3)
 VALUES ('John', 'Doe', 'john@example.com')";

 // Execute the sql statement
 if ($conn->query($sql) === TRUE) {
     echo "New record created successfully";
 } else {
     echo "Error: " . $sql . "<br>" . $conn->error;
 }
 // Close connection 
 $conn->close();
//初始化将捕获表单数据的变量
$first_nameparty=“”;
$middle_nameparty=“”;
$last_nameparty=“”;
//检查您请求的表单数据
如果(isset($_GET['Party']))
$first_nameparty=$_GET['Party'];
如果(isset($\u GET['Partytwo']))
$middle_nameparty=$_GET['Partytwo'];
如果(isset($_GET['Party3']))
$last_nameparty=$_GET['Party3'];
//数据库配置
$servername=“localhost”;
$username=“username”;
$password=“password”;
$dbname=“myDB”;
//创建连接
$conn=newmysqli($servername、$username、$password、$dbname);
//检查连接
如果($conn->connect\u错误){
die(“连接失败:”.$conn->connect\U错误);
} 
//SQL语句(字符串)
$sql=“插入到表名中(字段2、字段名2、字段名3)
价值观('John','Doe','john@example.com')";
//执行sql语句
if($conn->query($sql)==TRUE){
echo“新记录创建成功”;
}否则{
echo“Error:”.$sql.“
”$conn->Error; } //密切联系 $conn->close();
检查数据库中添加的记录

if (isset($_GET['party'])) {
    echo $_GET['party'];
}
if (isset($_GET['partytwo'])) {
    echo $_GET['partytwo'];
}
......
 // Initialize your variable that will catch for your form data
 $first_nameparty="";
 $middle_nameparty="";
 $last_nameparty =""; 
 // Check the form data of your request
 if (isset($_GET['Party'])) 
     $first_nameparty = $_GET['Party'];

 if (isset($_GET['Partytwo'])) 
     $middle_nameparty = $_GET['Partytwo'];

 if (isset($_GET['Party3'])) 
    $last_nameparty = $_GET['Party3'];
 // Database configuration
 $servername = "localhost";
 $username = "username";
 $password = "password";
 $dbname = "myDB";

 // Create connection
 $conn = new mysqli($servername, $username, $password, $dbname);
 // Check connection
 if ($conn->connect_error) {
     die("Connection failed: " . $conn->connect_error);
 } 

 // SQL STATEMENT (string)
 $sql = "INSERT INTO tablename (field2, fieldname2, fieldname3)
 VALUES ('John', 'Doe', 'john@example.com')";

 // Execute the sql statement
 if ($conn->query($sql) === TRUE) {
     echo "New record created successfully";
 } else {
     echo "Error: " . $sql . "<br>" . $conn->error;
 }
 // Close connection 
 $conn->close();