SajanParikh Posted October 10, 2007 Share Posted October 10, 2007 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.... <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. Quote Link to comment https://forums.phpfreaks.com/topic/72695-solved-please-help-php-n00b-email-something/ Share on other sites More sharing options...
SajanParikh Posted October 10, 2007 Author Share Posted October 10, 2007 I know how to use the php mail(), but how would I get the whole table into one variable to send in the message? Quote Link to comment https://forums.phpfreaks.com/topic/72695-solved-please-help-php-n00b-email-something/#findComment-366571 Share on other sites More sharing options...
pocobueno1388 Posted October 10, 2007 Share Posted October 10, 2007 You would get all that into one variable, like this <?php $var = "<TR CLASS=\"MYTABLE\">"; $var .= "<TD CLASS=\"MYTABLE\">" . $id . "</TD>"; $var .= "<TD CLASS=\"MYTABLE\">" . $date . "</TD>"; $var .= "<TD CLASS=\"MYTABLE\">" . $rooms . "</TD>"; $var .= "<TD CLASS=\"MYTABLE\">$" . $tax . "</TD>"; $var .= "<TD CLASS=\"MYTABLE\">$" . $misc . "</TD>"; $var .= "<TD CLASS=\"MYTABLE\">$" . $total1 . "</TD>"; $var .= "<TD CLASS=\"MYTABLE\"> </TD>"; $var .= "<TD CLASS=\"MYTABLE\">$" . $cash . "</TD>"; $var .= "<TD CLASS=\"MYTABLE\">$" . $bankcard . "</TD>"; $var .= "<TD CLASS=\"MYTABLE\">$" . $amex . "</TD>"; $var .= "<TD CLASS=\"MYTABLE\">$" . $directbill . "</TD>"; $var .= "<TD CLASS=\"MYTABLE\">$" . $total2 . "</TD>"; $var .= "</TR>"; ?> Now the $var variable contains the entire table. Quote Link to comment https://forums.phpfreaks.com/topic/72695-solved-please-help-php-n00b-email-something/#findComment-366575 Share on other sites More sharing options...
SajanParikh Posted October 10, 2007 Author Share Posted October 10, 2007 Really? That would work? pocobueno1388, I love you! Quote Link to comment https://forums.phpfreaks.com/topic/72695-solved-please-help-php-n00b-email-something/#findComment-366576 Share on other sites More sharing options...
Aureole Posted October 10, 2007 Share Posted October 10, 2007 Yeah it's called concatenation (I believe). It's very useful, I've found loads of great uses for it... Just in case you're wondering... how it works... and showing that you can use constants, strings etc. <?php $variable = 'Hello'; echo ''.$variable.'<br />'; // Output = "Hello" $variable .= ' my name is '; echo ''.$variable.'<br />'; // Output = "Hello my name is" define(MY_NAME, 'Aureole'); $variable .= MY_NAME; echo ''.$variable.'<br />'; // Output = "Hello my name is Aureole" $age = 18; $variable .= ' and I am '.$age.' Years old.'; echo $variable; // Output = "Hello my name is Aureole and I am 18 Years old. ?> Edit: Fixed a typo... Quote Link to comment https://forums.phpfreaks.com/topic/72695-solved-please-help-php-n00b-email-something/#findComment-366594 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.