Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我想当我点击一个链接时,执行一个php脚本,并将数据存储在我可以使用的数据库中_Php_Jquery_Html - Fatal编程技术网

我想当我点击一个链接时,执行一个php脚本,并将数据存储在我可以使用的数据库中

我想当我点击一个链接时,执行一个php脚本,并将数据存储在我可以使用的数据库中,php,jquery,html,Php,Jquery,Html,我在2.html页面中有此代码 <a href='1.php' >click me</a> <html> <head> <meta charset="utf-8"> <title> my page </title> </head> <body> <?php

我在
2.html
页面中有此代码

<a href='1.php' >click me</a>
<html>
    <head>
        <meta charset="utf-8">
        <title>
            my page
        </title>
    </head>
    <body>
        <?php 
        include('simple_html_dom.php');
        $html=file_get_html($url);
        foreach($html->find('a') as $element){
            $html2=$element->href;
        }

我想将
$html2
存储在数据库中,然后返回到我的第一页。对我宽容点。任何帮助都将不胜感激。

请在$html2后面的括号中添加以下代码

$html2=$element->href;

$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 = "INSERT INTO MyDataTable (htmlcontent)
VALUES ($html2)";

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

header("Location:myfirst.php");
die();
$html2=$element->href;
$servername=“localhost”;
$username=“username”;
$password=“password”;
$dbname=“myDB”;
//创建连接
$conn=newmysqli($servername、$username、$password、$dbname);
//检查连接
如果($conn->connect\u错误){
die(“连接失败:”.$conn->connect\U错误);
} 
$sql=“插入MyDataTable(htmlcontent)
价值($html2)”;
if($conn->query($sql)==TRUE){
echo“新记录创建成功”;
}否则{
echo“Error:”.$sql.“
”$conn->Error; } $conn->close(); 标题(“位置:myfirst.php”); 模具();
请将以下代码添加到$html2后面的括号中

$html2=$element->href;

$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 = "INSERT INTO MyDataTable (htmlcontent)
VALUES ($html2)";

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

header("Location:myfirst.php");
die();
$html2=$element->href;
$servername=“localhost”;
$username=“username”;
$password=“password”;
$dbname=“myDB”;
//创建连接
$conn=newmysqli($servername、$username、$password、$dbname);
//检查连接
如果($conn->connect\u错误){
die(“连接失败:”.$conn->connect\U错误);
} 
$sql=“插入MyDataTable(htmlcontent)
价值($html2)”;
if($conn->query($sql)==TRUE){
echo“新记录创建成功”;
}否则{
echo“Error:”.$sql.“
”$conn->Error; } $conn->close(); 标题(“位置:myfirst.php”); 模具();
我知道如何保存数据。我想在html2页面中使用它们。你可以使用blog数据类型来保存HTML页面。我知道如何保存数据。我想在html2页面中使用它们。您可以使用blog数据类型来保存HTML页面