我有一个基于web的签出表,其中显示了当前已签出资产的列表(它是通过从SQL表中提取变量来实现的)我希望获得相同的输出并将其发送到电子邮件中,但每次尝试时,我要么得到资源id#4,要么得到空白输出。出于保密的原因,我不能将邮件方面的源代码放在客户端上。下面的代码可以很好地显示在主站点上。环境正在使用WAMP,任何信息都将被盗用。
mysql_connect("127.0.0.1", "helpdesk", "Password" )or die("cannot connect");
mysql_select_db("loaner")or die("cannot select DB");
$table=mysql_query("SELECT * FROM signout");
echo "
<div id='status'> <table cellspacing='0' cellpadding='0' border=''>
<tr>
<th>Equipment Currently Out</th>
<th>By Who</th>
<th>Return Date</th>
</tr>";
while ($row = mysql_fetch_array($table))
{
echo "<tr>";
echo "<td>" . $row['Equip'] . "</td>";
echo "<td>" . $row['User'] . "</td>";
echo "<td>" . $row['Return Date'] . "</td>";
}
echo "</tr>";
echo "</table></div>";
echo "</table></div>";发布于 2013-12-10 05:29:31
请注意,$table中使用的换行符并不是必需的,我将它们留在那里只是为了让您更容易了解所发生的事情。
mysql_connect('127.0.0.1', 'helpdesk', 'Password' ) or die('cannot connect');
mysql_select_db('loaner')or die('cannot select DB');
$results = mysql_query('SELECT * FROM signout');
/**
* Store the HTML in a variable
*/
$table = "<div id='status'>
<table cellspacing='0' cellpadding='0' border=''>
<tr>
<th>Equipment Currently Out</th>
<th>By Who</th>
<th>Return Date</th>
</tr>";
while ( $row = mysql_fetch_array($results) ) {
$table .= "<tr>";
$table .= "<td>" . $row['Equip'] . "</td>";
$table .= "<td>" . $row['User'] . "</td>";
$table .= "<td>" . $row['Return Date'] . "</td>";
}
$table .= "
</tr>
</table>
</div>";
/**
* Mail the HTML
*/
$body = 'Blah blah blah '.$table.' blah blah blah';
mail($to, $from, $subject, $body);https://stackoverflow.com/questions/20479041
复制相似问题