try{
#connection string
// $dbconn = new PDO('mysql:host=localhost;port=3306;dbname=mycooldb',array(PDO::ATTR_PERSISTENT => true));
$dbconn = new PDO('mysql:host=localhost;port=3306;dbname=mycooldb','root','toshiba1',array(PDO::ATTR_PERSISTENT => true));
$q = $dbconn->prepare("SELECT FW_ArtSrcLink FROM FW_ArtSrc WHERE OneSet=1 and leagID=20");
#call stored proc
$q->execute();
#get the rows into an array
$result = $q->fetchAll();
$newsStory = array();
foreach($result as $r){
while($xmlUrl = $r['FW_ArtSrcLink']){
// WHILE there is a link out of 11 matching the $dbconn above, load XML file and convert to channel->item
$ConvertToXml = simplexml_load_file($xmlUrl);
$newsStory[] = $ConvertToXml->channel->item;
# -> Setup XML
} //while
}
# -----> Load News Stories
for($i = 0;$i<sizeof($newsStory); $i++){
//// judging by your code, these are the things you wanted to echo
# Source of Article Info-->
echo $newsStory[$i]->item->title;
echo $newsStory[$i]->item->link;
# Actual News Article Info -->
echo $newsStory[$i]->item->title;
echo 'desc: '.$newsStory[$i]->item->description;
} // for()
} // try
我需要上面代码的帮助。$ 查询有 11 个结果dbconn
,但我需要加载每个结果并进行转换,simplexml_load_file();
以便也可以加载具有 15-20 个链接的所有 11 条记录。总计约 *15*11= 165 个链接*
foreach($result as $r){
while($xmlUrl = $r['FW_ArtSrcLink']){
// WHILE there is a link out of 11 matching the $dbconn above, load XML file and convert to channel->item