Hi I have a very simple database and one record in a table has 5 fields. each record has a field that denotes the record as active. I can retrieve the records and display them without a problem. I can email the contents of ONE record at a time as they are created using sendmail and the $_POST values. What I am struggling with is- If multiple records are set as active, how do I create an array of those records and email that array in a legible format? Ive spent hours trawling the net reading stuff and am just confusing myself even more. I'm not a programmer but I'm not dumb either, i can follow some simple instructions if anyone has the time to share some! ideally i would like to create something that looks like - column 1 | Column2 | Column 3 | Val1 val2 val3 etc. thanks in advance Canoman5
the basic mail command is mail($email, $subject, $body); PHP: so if you have info you want to put in the email it's as simple as this $sql = "select * from `mytable`"; $result = mysql_query($sql) or die(mysql_error.'<br />'.$sql); $body = ''; while ($row = mysql_fetch_array($result){ for($i=0; $i<5; $i++){ $body .= $row[$i]. "\t"; } $body .= "\n"; } mail($email, $subject, $body); PHP: you still have to populate the email and subject fields.
Here's a possible way, you get the count of records in table, and store in a variable. You can query each record for each information you need to be pulled from the table/database and store it using simple PHP arrays, with a key if possible. Use a for loop, where $i is less than count of records until it's met or equal to it. Output the data using "/t" for aligning.
I would do what Sarah said adding the field names (would make it easier to read, at least for me it would): while ($row = mysql_fetch_assoc($result){ $body .= print_r($row, true) . "\n"; } PHP: