Text string in php email

Hi there hope someone can help. (i’m new to php and sql)

I’ve put together a couple of queries that builds a table. This table is to go into an email to each user on a database.

I’ve tested this by outputting the results to a website and it all works fine - it displays the emails as I want it to (one after the other) so all I need to do now is set it up so that it can be emailed.

I am struggling with how to build the body string - I can do every bit until the table is built.

I basically have an SQL query that I use for the start of the body text (creates $body1, $body2, $body3 (headings of table) for each user and then the following code below and then $body5… etc. for the end of the body. I then just want to join them together for the email. (which I can do) But how do I get the whole of the table below into a string ($body4) - can I just put something around it all? Using $bodyX just returns the last row as you would expect and including the mail function within this part results in several emails to the same user.

Please help

Thanks in advance

while($row2 = mysql_fetch_array($sql2)){

if ((strtolower($row2[“ad_town”]) == strtolower($targettown) OR strtolower($row2[“ad_town”]) == strtolower($target2town) OR strtolower($row2[“ad_town”]) == strtolower($target3town)) AND (strtolower($row2[“ad_townseek”]) == strtolower($mytown) OR strtolower($row2[“ad_alttownseek”]) == strtolower($mytown) OR strtolower($row2[“ad_altalttownseek”]) == strtolower($mytown))) {
$matchtype = ‘Exact’;
} ELSE {
$matchtype = ‘County’;
}
$adverttown = $row2[“ad_town”];
$adheadline = $row2[“ad_headline”];
$nobeds = $row2[“ad_nobeds”];
$rent = $row2[“ad_rent”];
$adid = $row2[“13”];

$bodyX = ’

' . $matchtype . ' ' . $adverttown . ' ' . $adheadline . ' ' . $nobeds . ' £ ' . $rent . ' view ';

echo $bodyX;
}

Hi there,

I’ve literally just done this from theory as I do not have your SQL query, but the following should work - if not let me know what is failing (add “error_reporting(E_ALL);” to top of script if errors aren’t already displaying).

[php]<?php
$bodyX = ‘’;
while($row2 = mysql_fetch_array($sql2)) {

if ((strtolower($row2["ad_town"]) == strtolower($targettown) OR strtolower($row2["ad_town"]) == strtolower($target2town) OR strtolower($row2["ad_town"]) == strtolower($target3town)) AND (strtolower($row2["ad_townseek"]) == strtolower($mytown) OR strtolower($row2["ad_alttownseek"]) == strtolower($mytown) OR strtolower($row2["ad_altalttownseek"]) == strtolower($mytown))) {
    $matchtype = 'Exact';
} ELSE {
    $matchtype = 'County';
}
$adverttown = $row2["ad_town"];
$adheadline = $row2["ad_headline"];
$nobeds = $row2["ad_nobeds"];
$rent = $row2["ad_rent"];
$adid = $row2["13"];



$bodyX .= '
' . $matchtype . ' ' . $adverttown . ' ' . $adheadline . ' ' . $nobeds . ' £ ' . $rent . ' view '; } echo $bodyX; ?>[/php]

anyone?

Sorry didn’t see the last post for some reason. Thanks I’ll give it a try.

Sponsor our Newsletter | Privacy Policy | Terms of Service