Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Please help PHP n00b email something

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

FTN BLZZRD

Established Member
Impact
0
Alright...well, I'm very new to PHP and this is my first little script I'm doing for work. I have EVERYTHING working....

  • User Enters Information On Form
  • Form takes information and stores in MySQL
  • There is also a page to display the MySQL results in a table

Here is the result table....

Code:
        <TBODY>
    <?php
//Client Loop
$i=0;
while ($i < $num_rows) {

$id = mysql_result($query,$i,"id");
$date = mysql_result($query, $i, "date");
$rooms = mysql_result($query, $i, "rooms");
$tax = mysql_result($query, $i, "tax");
$misc = mysql_result($query, $i, "misc");
$total1 = mysql_result($query, $i, "total1");
$cash = mysql_result($query, $i, "cash");
$bankcard = mysql_result($query, $i, "bankcard");
$amex = mysql_result($query, $i, "amex");
$directbill = mysql_result($query, $i, "directbill");
$total2 = mysql_result($query, $i, "total2");

echo "<TR CLASS=\"MYTABLE\">";
echo "<TD CLASS=\"MYTABLE\">" . $id . "</TD>";
echo "<TD CLASS=\"MYTABLE\">" . $date . "</TD>";
echo "<TD CLASS=\"MYTABLE\">" . $rooms . "</TD>";
echo "<TD CLASS=\"MYTABLE\">$" . $tax . "</TD>";
echo "<TD CLASS=\"MYTABLE\">$" . $misc . "</TD>";
echo "<TD CLASS=\"MYTABLE\">$" . $total1 . "</TD>";
echo "<TD CLASS=\"MYTABLE\">   </TD>";
echo "<TD CLASS=\"MYTABLE\">$" . $cash . "</TD>";
echo "<TD CLASS=\"MYTABLE\">$" . $bankcard . "</TD>";
echo "<TD CLASS=\"MYTABLE\">$" . $amex . "</TD>";
echo "<TD CLASS=\"MYTABLE\">$" . $directbill . "</TD>";
echo "<TD CLASS=\"MYTABLE\">$" . $total2 . "</TD>";
echo "</TR>";
$i++;
}
mysql_close();
?>
    </TBODY>

This will obviously create multiple rows based on how many results there are. Which then makes a full table of multiple rows.

I now want to send this FULL table (all results) via email using PHP. How can this be done? Any links would be really appreciated.
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
If i understand you correctly, you are going to get those data as a text and e-mail it? You can record the output buffer before sending it to browser, and use the same template to e-mail.

PHP:
<?PHP

ob_start();   // start here

echo '<TBODY>';
    
//Client Loop
$i=0;
while ($i < $num_rows) {

$id = mysql_result($query,$i,"id");
$date = mysql_result($query, $i, "date");
$rooms = mysql_result($query, $i, "rooms");
$tax = mysql_result($query, $i, "tax");
$misc = mysql_result($query, $i, "misc");
$total1 = mysql_result($query, $i, "total1");
$cash = mysql_result($query, $i, "cash");
$bankcard = mysql_result($query, $i, "bankcard");
$amex = mysql_result($query, $i, "amex");
$directbill = mysql_result($query, $i, "directbill");
$total2 = mysql_result($query, $i, "total2");

echo "<TR CLASS=\"MYTABLE\">";
echo "<TD CLASS=\"MYTABLE\">" . $id . "</TD>";
echo "<TD CLASS=\"MYTABLE\">" . $date . "</TD>";
echo "<TD CLASS=\"MYTABLE\">" . $rooms . "</TD>";
echo "<TD CLASS=\"MYTABLE\">$" . $tax . "</TD>";
echo "<TD CLASS=\"MYTABLE\">$" . $misc . "</TD>";
echo "<TD CLASS=\"MYTABLE\">$" . $total1 . "</TD>";
echo "<TD CLASS=\"MYTABLE\">   </TD>";
echo "<TD CLASS=\"MYTABLE\">$" . $cash . "</TD>";
echo "<TD CLASS=\"MYTABLE\">$" . $bankcard . "</TD>";
echo "<TD CLASS=\"MYTABLE\">$" . $amex . "</TD>";
echo "<TD CLASS=\"MYTABLE\">$" . $directbill . "</TD>";
echo "<TD CLASS=\"MYTABLE\">$" . $total2 . "</TD>";
echo "</TR>";
$i++;
}
mysql_close();

echo '</TBODY>';

$mailbody = ob_get_contents();
ob_end_flush();   // end here

// HTML HEADERS
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: somewhere <[email protected]>' . "\r\n";

mail("[email protected]","subject",$mailbody,$headers);
?>
 
0
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back