/    Sign up×
Community /Pin to ProfileBookmark

I seemto have an issue with my loop in the below code. I have 3 mp3 files and 3 corresponding xml files for listing podcasts on my page. When displaying them on the page, it displays the first mp3 2 times, then the second mp3, then it displays mp3 1, 2, 3 in the correct order. Can anyone tell me why?

[code=php]
<?
include(“$absoluteurl”.”podcasts/core/supported_media.php”);
//load XML parser for PHP4 or PHP5
include_once(“$absoluteurl”.”podcasts/components/xmlparser/parser_php5.php”);

// Open podcast directory
$handle = opendir ($absoluteurl.$upload_dir);
while (($filename = readdir ($handle)) !== false)
{

if ($filename != ‘..’ && $filename != ‘.’ && $filename != ‘index.htm’ && $filename != ‘_vti_cnf’ && $filename != ‘.DS_Store’)
{

$file_array[$filename] = filemtime ($absoluteurl.$upload_dir.$filename);
}

}

if (!empty($file_array)) { //if directory is not empty
?>
<h2><img src=”images/podcast_icon.png” width=”20″ height=”20″ alt=”Podcasts” title=”Podcasts” class=”multimedia” /><a href=”/podcasts/” title=”Podcasts”>Podcasts</a></h2>
<?
# asort ($file_array);
arsort ($file_array); //the opposite of asort (inverse order)
//print_r($file_array);

$recent_count = 0; //set recents to zero

foreach ($file_array as $key => $value) {

$file_multimediale = explode(“.”,$key); //divide filename from extension [1]=extension (if there is another point in the filename… it’s a problem)

$fileData = checkFileType($file_multimediale[1],$podcast_filetypes,$filemimetypes);

if ($fileData != NULL) { //This IF avoids notice error in PHP4 of undefined variable $fileData[0]

$podcast_filetype = $fileData[0];

if ($file_multimediale[1]==”$podcast_filetype”) { // if the extension is the same as specified in config.php

$file_size = filesize(“$absoluteurl$upload_dir$file_multimediale[0].$podcast_filetype”);
$file_size = $file_size/1048576;
$file_size = round($file_size, 2);

############
$filedescr = “$absoluteurl”.”$upload_dir$file_multimediale[0].xml”; //database file

if (file_exists(“$filedescr”)) { //if database file exists

//$file_contents=NULL;

# READ the XML database file and parse the fields
include(“$absoluteurl”.”podcasts/core/readXMLdb.php”);

### Here the output code for the episode is created

# Fields Legend (parsed from XML):
# $text_title = episode title
# $text_shortdesc = short description
# $text_longdesc = long description
# $text_imgpg = image (url) associated to episode
# $text_category1, $text_category2, $text_category3 = categories
# $text_keywordspg = keywords
# $text_explicitpg = explicit podcast (yes or no)
# $text_authornamepg = author’s name
# $text_authoremailpg = author’s email

$PG_mainbody .=
‘<div class=”multimedia-list”>
<p>’.$text_title.'</p>’;
include (“$absoluteurl”.”podcasts/components/player/player.php”);
$PG_mainbody .= ‘<p>’.$showplayercode.'</p>’;

$PG_mainbody .= “</div>”;
echo $PG_mainbody;
}

}
}
}

}
?>
[/code]

Here’s a link to the page: [URL=”http://www.zluth.org/multimedia/”]http://www.zluth.org/multimedia/[/URL]
Thanks!

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@andydrizenMar 24.2008 — your link is dead :F
Copy linkTweet thisAlerts:
@jrthor2authorMar 24.2008 — it should be fine now
Copy linkTweet thisAlerts:
@jrthor2authorMar 24.2008 — i fixed it. I had it echoing the body content inside the for loop, instead of outside the loop.
×

Success!

Help @jrthor2 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...