Thanks! I took what you wrote, looked at it a bit, and read up on eregi() (on php.net). I then found a little more, and got what I was looking for!
The purpose of this script is to take some updates that were made to what was already in a db and paste it back in. it's the 2nd half of two scripts:
1)pull the data from the db and save it to txt files
(update in editor)
2)put data back into db.
Thanks again. problem solved.
<?php
/ grabbing parts out of an html file /
/ basically, all I'm doing is putting data back into my db /
1. dbconnection
require("dbconnect.php");
$query = mysql_query("SELECT id, section, pagetype, header, format, footer from gc_layouts where pagetype !='front' and pagetype !='zero'");
2. base path to files
$filelocal = "/path/to/files/";
3. the function. here's the magic
function getdata($path, $datatype) {
$pagefile = fopen($path, "r");
$data = fread($pagefile, filesize($path));
if (eregi("<!--" . $datatype . "-->(.*)<!--/" . $datatype . "-->", $data, $out)) {
$outdata = $out[1];
}
return $outdata;
}
4. the array, and the loop
while($row = mysql_fetch_array($query)){
$section = $row['section'];
$pagetype= $row['pagetype'];
$filepart = "$filelocal$section-$pagetype.html";
$header = getdata($filepart,"before");
$format = getdata($filepart,"format");
$footer = getdata($filepart,"footer");
}
?>