【发布时间】:2015-08-14 13:11:50
【问题描述】:
我需要帮助将我的 div 存储到 php 会话中。
<div name = "divResults">
(display results from mysql)
</div>
我需要做的是:
->按日期搜索记录。
->结果将显示在下一页。
->会有一个发送电子邮件的按钮。
->我的 div 中的结果将通过电子邮件发送给用户。
我可以发送电子邮件,但无法发送结果。我试过用这个
这是我搜索日期后的结果页面代码:
<div name = "divResults">
<?php
$getquery = mysql_query("SELECT * FROM Records WHERE Date = '".$sdbStart."' AND Records.SerialNumber NOT IN (SELECT SerialNumber FROM ImportData WHERE Date ='".$adbStart."') ORDER BY Date DESC LIMIT $start, $per_page");
$_SESSION['getquery'] = $getquery;
echo "<table id=wTable>";
echo "<table id=hTable style=width:800px; border=1px;>
<tr style=background-color:black;color:yellow;font-size:18px;>
<th style=width:25px>ID</th>
<th style=width:200px>Username</th>
<th style=width:175px>Date</th>
<th style=width:225px>Serial Number</th>
<th style=width:200px>Location</th>
</tr>";
echo "</table>";
echo "<div id ='test' style=width:820px;height:200px;overflow:auto;>";
echo "<table id=dTable width=800px border=1px>";
while($row = mysql_fetch_assoc($getquery))
{
$r +=1;
echo "<tr style=color:black;background-color:lightgrey;font-size:13px;>";
echo "<td style=width:25px>" . $r . "</td>";
echo "<td style=width:200px>" . $row['Username'] . "</td>";
echo "<td style=width:175px >" . $row['Date'] . "</td>";
echo "<td style=width:225px>" . $row['SerialNumber'] . "</td>";
echo "<td style=width:200px>" . $row['Location'] . "</td>";
echo "</tr>";
}
echo "</table>";
echo "</table>";
echo "</div>";
?>
</div>
<form method = "POST" action = "email-controller.php">
<font style ="color:orange"><b>From :</b></font>
<input type = "text" name = "sender" id = "sender" value = "<?php echo $_SESSION['email']; ?>" class = "sender">
<font style ="color:orange"><b>Send to :</b></font>
<input type = "text" name = "recipient" id = "recipient">
<input type = "submit" name = "sendEmail" id = "sendEmail" value = "Send">
</form>
这是我的 email-controller.php 代码
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0;URL=autogeneratereport.php" />
</head>
<?php
$conn = mysql_connect('localhost', 'un', 'pw');
mysql_select_db('db');
$sender = $_POST['sender'];
$recipient = $_POST['recipient'];
$_SESSION['divData'] = $_POST['divData'];
session_start();
$_SESSION['sender'] = $sender;
$_SESSION['recipient'] = $recipient;
$senderQuery = mysql_query("SELECT * FROM Users WHERE Email = '".$sender."'");
$senderData = mysql_fetch_array($senderQuery);
$_SESSION['senderEmail'] = $senderData['Email'];
$_SESSION['senderFN'] = $senderData['FullName'];
$recipientQuery = mysql_query("SELECT * FROM Users Where Email = '".$recipient."'");
$recipientData = mysql_fetch_array($recipientQuery);
$_SESSION['recipientEmail'] = $recipientData['Email'];
$_SESSION['recipientFN'] = $recipientData['FullName'];
$getquery = $_SESSION['getquery'];
?>
【问题讨论】:
-
请分享您的代码。到目前为止你尝试过什么?
标签: javascript php ajax html session