[英]How to use phpQuery and SQL?
我需要检查sql表中是否来自$ var的数据,并设置StopTime参数。 但是出现错误:为foreach()提供了无效的参数。 问题是什么?
$url='http://somesite/';
$pars = file_get_contents($url);
$document = phpQuery::newDocument($pars);
$var=$document->find('td:nth-child(10n)')->text();
foreach ($var as $value){
$query = "UPDATE (
SELECT `Id`id, `UserName`
FROM `table`
WHERE `UserName` IN ('".$value."')
)unic_table
JOIN `table` as r ON r.`Id` = unic_table.id
SET r.`StopTime` = now( ) ";
$result = mysql_query($query);
}
您正在尝试迭代:
$document->find('td:nth-child(10n)')->text()
这是一个字符串。 你要:
$document->find('td:nth-child(10n)')
这是一个DomNodeList
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.