hanwei Posted November 2, 2006 Share Posted November 2, 2006 hi guys,how can i get the whole table from my data and display it to my mail??the structure of the table is as below when i do a select statement: --------------------------ttNo:1ttCompany:GRttStatus:AssignedttEngrAsgn:hanwei--------------------------ttNo:2ttCompany:GRttStatus:AssignedttEngrAsgn:hanwei--------------------------ttNo:3ttCompany:GRttStatus:ClosedttEngrAsgn:hanwei--------------------------ttNo:4ttCompany:GRttStatus:AssignedttEngrAsgn:hanwei--------------------------i have tried the following script:[code]<?php$link = mysql_connect("127.0.0.1", "mysql") or die("Could not connect: " . mysql_error());mysql_select_db("ttmodule", $link) or die("Unable to select database: . mysql_error()");$selectSqlOne= "SELECT * FROM indexpri ORDER BY indexPriNo ASC ";$resultOne = mysql_query($selectSqlOne, $link);if(!$resultOne) die("Invalid Query: " .mysql_error() ."<br>" .$selectSqlOne);while($row = mysql_fetch_array($resultOne)){ $secondaryTbl = $row["indexSecTbl"]; $selectSqlTwo= "SELECT * FROM $secondaryTbl ORDER BY indexSecNo ASC "; $resultTwo = mysql_query($selectSqlTwo, $link); if(!$resultTwo) die("Invalid Query: " .mysql_error() ."<br>" .$selectSqlTwo);while($row = mysql_fetch_array($resultTwo)){ $mainTbl = $row["mainTbl"]; $selectSqlThree="SELECT ttNo, ttCompany, ttStatus, ttEngrAsgn FROM $mainTbl where ttStatus='Closed' ORDER BY ttNo ASC"; $resultThree = mysql_query($selectSqlThree, $link); if(!$resultThree) die("Invalid Query: " .mysql_error() ."<br>" .$selectSqlThree);while($row=mysql_fetch_array($resultThree)){ $to = "hanwei<[email protected]>"; $subject = "test"; $message = ""; $headers = "From: [email protected]\r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; mail($to, $subject, $message, $headers);}}}?>[/code]the script works fine when i input the message as : $message=$row["ttNo"]; it will only display the ttNo.but i want to display the whole table where ttStatus!='Closed'.so how do i continue from here? or my script is totally wrong?do i have to create a table border for it? i just want to display a simple table containing the variable. This table will allow the administrator to find out which company's not in Closed status.thanks Link to comment https://forums.phpfreaks.com/topic/25921-email-get-table-from-database/ Share on other sites More sharing options...
trq Posted November 2, 2006 Share Posted November 2, 2006 [code=php:0]$message .= $row['ttNo']."\n".$row['ttCompany']."\n".$row['ttStatus']."\n".$row['ttEngrAsgn']."\n\n--------------------------";[/code] Link to comment https://forums.phpfreaks.com/topic/25921-email-get-table-from-database/#findComment-118370 Share on other sites More sharing options...
hanwei Posted November 2, 2006 Author Share Posted November 2, 2006 thanks for your help. i will try the script again. Link to comment https://forums.phpfreaks.com/topic/25921-email-get-table-from-database/#findComment-118373 Share on other sites More sharing options...
hanwei Posted November 3, 2006 Author Share Posted November 3, 2006 hi,i have tried:$message = "Ticket Number:"."\n".$no."<br></br>"."Company:"."\n".$comp."<br></br>"."Status:"."\n".$stat."<br></br>"."Engineer Assigned:"."\n".$engr."<br></br>"."\n--------------------------";and it will only print out the highest ticket number: Ticket Number: 4 Company: GR Status:Assigned Engineer Assigned: hanweiso what can i do to make my message display all the data??example: -------------------------ttNo:1ttCompany:GRttStatus:AssignedttEngrAsgn:hanwei--------------------------ttNo:2ttCompany:GRttStatus:AssignedttEngrAsgn:hanwei--------------------------ttNo:4ttCompany:GRttStatus:AssignedttEngrAsgn:hanwei--------------------------and if i want to have a print out like :------------------------------------------------------------------------------------l Number l Company l Status l EngineerAssigned l------------------------------------------------------------------------------------ 1 GR Assigned hanwei 2 GR Assigned hanwei 4 GR Assigned hanwei-------------------------------------------------------------------------------------do i have to change my script?thanks Link to comment https://forums.phpfreaks.com/topic/25921-email-get-table-from-database/#findComment-118873 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.