//首先,我分配一个$变量($ emailzipmatch)来查询一个名为(repzipcodes)的数据库表,并让它拉和显示1到3条记录基于匹配up客户的邮政编码(RepZipCode = $ CustomerZipMatch)与1〜3等人(GROUP BY REPID HAVING COUNT(1)< = 3" )希望该客户从该特定邮政编码信息。重命名和插入数组结果到不同的表
//代码工作BELOW
$emailzipmatch = mysql_query("SELECT * FROM repzipcodes WHERE RepZipCode = $CustomerZipMatch GROUP BY RepId HAVING COUNT(1) <= 3") or die(mysql_error());
$recipients = array();
while($row = mysql_fetch_array($emailzipmatch))
{
$recipients[] = $row['RepEmail'];
echo "Agent's Email Address: ";
echo 'font color="#FF7600"',$row['RepEmail'], '/font';
echo '<br />';
echo "Rep's ID: ";
echo '<br />';
echo 'font color="#FF7600"',$row['RepId'], '/font';
echo '<br />';
echo 'hr align="left" width="50%" size="2" /';
}
//我的问题BELOW
//对于上面的过程中的下一步,我将采用$ row ['RepEmail']和$ row ['RepId'],它可以有1到3个结果,并将1到3的结果赋给一个新的$变量,被插入到不同的数据库表,所以我可以跟踪从页面顶部的查询($ emailzipmatch =)的结果:即..
<New Variable> <Listed from above>
$SentRepId 0 = RepId (results from above echo area)
$SentRepId 1 = RepId (results from above echo area)
$SentRepId 2 = RepId (results from above echo area)
//下面我想插入上述结果到一个新的数据库
$?Variable??? = mysql_query("INSERT INTO sentemail
(SentRepId0, SentRepId1, SentRepId2,SentDateTime
) VALUES (
'$_SESSION[RepId]', // ?????
'$_SESSION[RepId]', // ?????
'$_SESSION[RepId]', // ?????
NOW()
)") or die(mysql_error());
//谢谢你提前帮助你们给我任何帮助。如果我的代码或请求不清楚,或者由于我缺乏PHP和MySQL的经验而导致混淆,请回答任何问题。
感谢您的解决方案,我正在改变我的流程。我只是使用解决方案中的“INSERT”部分,并且为每个结果创建了不同的记录,所以我将简化自己并取出($ SentRepId0 = RepId,$ SentRepId1 = RepId等)只能创建1条记录,只需要创建1到3条记录的单独记录。我只是跟踪哪个Rep获得“x”个结果。所以,非常感谢您的解决方案! – Wiley
不用担心:)祝你好运。 –