我正在尝试使用 Facebook Open Graph 从数组中获取数据。我正在使用 foreach 语句获取数组,但这会生成 6 个不同的 INSERT 语句。我希望数组中的每个值都能够提交到一个 MYSQL 行中。
请注意,$insert2 插入了 6 个不同的行,而 $insert 3 插入了一行,但只是 $urlform。
任何帮助将不胜感激。
代码是:
require_once('OpenGraph.php');
$urlget2 = "http://www.example.com/article/1/title";
$graph = OpenGraph::fetch($urlget2);
foreach ($graph as $key => $value) {
$array = array($key => $value);
print_r($array);
$key = type;
$key1 = title;
$key2 = image;
$key3 = description;
$key4 = url;
$subtype = $array[$key];
$subtitle = $array[$key1];
$subimage = $array[$key2];
$subdesc = $array[$key3];
$urlform = $array[$key4];
$useridme = "5";
$insert2 = "INSERT INTO share VALUES('','$urlform','$subtype','$subtitle','$subimage','$subdesc','$subtime','$datesubmit','$subevent','$useridme','$facebookidme','$grpurl')";
echo "<hr />";
echo $insert2;
}
echo "<hr />";
$insert3 = "INSERT INTO share VALUES('','$urlform1','$subtype','$subtitle','$subimage','$subdesc','$subtime','$datesubmit','$subevent','$useridme','$facebookidme','$grpurl')";
echo "<hr />";
echo $insert3;