Jump to content

How to get respective information ready for email


andz

Recommended Posts

I have these tables and sample contents:

 

jobs_table

  id, title, catid, content

 

  1, first title, 1, first content

  2, second title, 1, second content

  3, third title, 2, third content

  4, fourth title, 2, fourth content

 

 

category_table

  catid, name

 

  1, first category

  2, second category

 

 

users_table

  email, name, catid

 

  test@localhost.com, test user, 1~2

  test2@localhost.com, test2 user, 1

  test3@localhost.com, test3 user, 2

  test4@localhost.com, test4 user, 1~2

 

 

I already knew how to make the catid in users_table readable.

 

I'm trying to send an email. The email contains the job title of the jobs linked by the catid the users choose.

 

My problem is that, how can I load all the users and the same time the job information to be ready for the email?

 

The expected output will be:

 

 

test@localhost.com

  first title

  second title

  third title

  fourth title

 

test2@localhost.com

  first title

  second title

 

test3@localhost.com

  third title

  fourth title

 

test4@localhost.com

  first title

  second title

  third title

  fourth title

 

 

Sorry for my poor grammar.

 

I already done certain email functions, but this one gives me a little problem. I don't know where to start. Though I already started it by getting all the users information, extract catid array into readable array. Fetch all the information from job table based on catid for every user,,, but it seemed to have a problem.

 

thanks and more power...

 

If posible, pls include codes...

Link to comment
Share on other sites

If you have all th information in an array, just concatenate the info as a string (in an email newlines are '\n'). Like so:

<?php
$message = $data['user1email']."\n".$data['user1title1']."\n".$data['user1title2']."\n";
$message .= $data['user1title3']."\n".$data['user1title4']."\n\n";
$message .= $data['user2email']."\n".$data['user2title1']."\n".$data['user2title2']."\n\n";
$message .= $data['user3email']."\n".$data['user3title3']."\n".$data['user3title4']."\n\n";
$message .= $data['user4email']."\n".$data['user4title1']."\n".$data['user4title2']."\n";
$message .= $data['user4title3']."\n".$data['user4title4']."\n\n";
$subject = "Data extracted from database";
$to = "youname@yourdomain.com";
mail($to, $subject, $message);
?>

 

Hope that helps.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.