View Single Post
Old 02-10-2007, 02:54 PM   #6 (permalink)
roseau
Platinum Lifetime Member
 
Last Online: 08-02-2008 10:45 PM
iTrader: (5)
Join Date: Dec 2002
Posts: 89
DNF$: 534
Location: Canada
Country:


Re: php - change order of entries

I really appreciate the responses guys. I am sorry I wasn't more specific. I should have really said up front that it is not an sql database.

I'll post the code which I should have done in the beginning :(
The articles just go into an article folder.

Here's the full code:

Quote:
<?php

$folder = "/server path/domainnamehere.com/articles";

$dirhandle = opendir("$folder");
while($file_name = readdir($dirhandle)) {
if ($file_name != "."
&& $file_name != ".."
&& $file_name != "list.php"
&& $file_name != "index.html"
) {

// DO THIS FOR EACH FILE

// get contents of a file into a string

$filename = "$folder/$file_name";

$handle = fopen($filename, "rb");
$contents = fread($handle, 1000);
fclose($handle);

$matches = "";

// EXTRACT Title
if(preg_match("'<title>(.+)</title>'i", $contents, $matches)){
$title = $matches[1];
print("<div class=\"medium-header\"><A HREF=\"$file_name\">$title</A></div>");
$matches = "";
}



// EXTRACT Description
if(preg_match("'<META NAME=\"Description\" CONTENT=\"(.+)\">'i", $contents, $matches)){
$description = $matches[1];
print("$description<BR><BR><HR>");
$matches = "";
}


print("");

}
}

?>
Thx again for helping.
roseau is offline   Reply With Quote