I have an email function that looks like:
function send_email_with_attachment($to, $from, $email_att, $subject, $body)
I have 2 tables that this function gets its data from to send emails:
- emails
- email_attachments
emails has the columns:
- sequence
- emailto
- emailfrom
- subject
- message
and *email_attachmentss* has the columns:
- sequence
- email_seq (matches sequence from the emails table)
- attachment
So i want to be able to select a row from the emails table and then select all the related rows in the *email_attachments* table and send all the attachments in one email
whats the best way to do this?
I usually do things like:
$sql="SELECT * from table1 where col = 'condition' ";
$rs=mysql_query($sql,$conn);
while($result=mysql_fetch_array($rs))
{
$sql2="SELECT * from table2 where table1_col = '".$result["col"]."' ";
$rs2=mysql_query($sql2,$conn);
$result2=mysql_fetch_array($rs2);
}....
mysql_xxx()functions are deprecated and obsolete. You should consider converting your code to use the PDO library instead.