Page 1 of 1

Edit html file fields

Posted: Tue Apr 15, 2008 4:46 am
by JohnSan
Hi guys,

I need to upload a file in html format to a database, shouldn't be a problem using text or blobs.

I then need to edit this html file, changing name feilds in it to names in my database for several people.

Then email them.

The uploading and emailing isn't a problem but I am having trouble finding resources to help me change the feilds in the html file.

Any help anyone could provide would be greatly appreciated.

Thanks

Re: Edit html file fields

Posted: Tue Apr 15, 2008 7:41 am
by Kadanis
So basically you want a mail merge.

Loop over the email send, changing the html each time based on the name in the database.

I've used generic variables for the FOR loop, but they are meant to represent the record set extracted from the database table

Code: Select all

 
 
for ($start_of_resultset; !$end_of_resultset; $next_row_in_set) {
    #get name from active row in recordset
    $name = $resultset['name']; 
 
    #string replace the fieldname in the html with the name from the db
    $new_html = str_replace($field_in_html, $name, $default_html);
 
    #send the email using the html as the body content
    mail($to, $subject, $new_html);
}
 
This is the rough idea anyway. Hope it helps