Edit html file fields

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JohnSan
Forum Newbie
Posts: 1
Joined: Tue Apr 15, 2008 4:37 am

Edit html file fields

Post 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
User avatar
Kadanis
Forum Contributor
Posts: 180
Joined: Tue Jun 20, 2006 8:55 am
Location: Dorset, UK
Contact:

Re: Edit html file fields

Post 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
Post Reply