我想在 mysql 表中插入一个数组。该数组是通过脚本扫描所有链接,转换为绝对链接,然后将它们显示在一个数组中生成的。我决定将 mysql_query 数组放入表中,但现在我被卡住了。它只发布“数组”,而不是将数组中的每一行发布到不同的行中。有任何想法吗??!
<?php
require_once('simplehtmldom_1_5/simple_html_dom.php');
require_once('url_to_absolute/url_to_absolute.php');
$connect = mysql_connect("xxxx", "xxxx", "xxx") or die('Couldn\'t connect to MySQL Server: ' . mysql_error());
mysql_select_db("xxxx", $connect ) or die('Couldn\'t Select the database: ' . mysql_error( $connect ));
$links = Array();
$URL = 'http://www.theqlick.com'; // change it for urls to grab
// grabs the urls from URL
$file = file_get_html($URL);
foreach ($file->find('a') as $theelement) {
$links[] = url_to_absolute($URL, $theelement->href);
}
print_r($links);
mysql_query("INSERT INTO pages (url) VALUES ('$links[]')");
mysql_close($connect);