0
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
我需要上述代碼的幫助。 $ dbconn
查詢有11個結果,但我需要每個結果加載並使用simplexml_load_file();
進行轉換,以便可以加載所有11條具有15-20個鏈接的記錄。共計約* 15 * 11 = 165個賓館在foreach循環中輸出XML項目
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
雖然這讓我回到了原點。我需要得到所有標題,desc,從每個來源鏈接。目前有11個來源正在被拉。每個來源有〜15-20項。所以15 * 11 = 165鏈接...我只有11個,請參閱上面的更新代碼。我會很感激,如果你進一步幫助@Steve – CodeTalk 2012-08-01 23:28:53
當你echo $ newsStory [$ i] - >標題;它說「數組()」還是它給一個字符串標題? – Steve 2012-08-02 04:27:31
不,它迴應所有的標題,但只有其中的11個 – CodeTalk 2012-08-03 23:45:40