Hi,
I am trying to have the following script sent via e-maile.
This info will be gathered from a form. I am trying to add a loop that will alow 22 different rows, and rather than typing out 22 different rows I am trying to create a loop that will increase the
."<tr>"
."<td align=\"left\">$pn"
."<td align=\"left\">$desc"
."<td align=\"left\">$rec"
."<td align=\"left\">$qty"
."</tr>"
up to
."<tr>"
."<td align=\"left\">$pn22"
."<td align=\"left\">$desc22"
."<td align=\"left\">$rec22"
."<td align=\"left\">$qty22"
."</tr>"
I have tried the following but continue getting an error message:
Parse error: parse error, unexpected T_FOR in c:\www\safreq.php on line 66
ERROR ON LINE: (for($i=1;$i<22;$i++) {)
for($i=1;$i<22;$i++) {
if($POST['qty'.$i] AND ($POST['pn'.$i] AND ($POST['desc'.$i] AND ($POST['rec'.$i])))) {
echo "<tr>"
."<td align=\"left\">".$_POST['pn'.$i]
."<td align=\"left\">".$_POST['desc'.$i]
."<td align=\"left\">".$_POST['rec'.$i]
."<td align=\"left\">".$_POST['qty'.$i];
}
}
Can anyone please let me know what I am doing wrong?
The original script is below.
<?
$to = "billy.murray@avnet.com";
$subject = "Supplies Request Form";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "Cc: billy.murray@avnet.com\r\n";
$mailed = mail($to, $subject,
"<html>"
."<head>"
."<title>Supplies Request</title>"
."</head>"
."<body>"
."<left>"
."<h2><b>Safety Supplies Request</h2>"
."</left>"
."<br><br>"
."<br>"
."</b>"
."<b>A Supplies request was submitted by:\n</b>"
."<br><br>"
."<TABLE border=\"1\" cellPadding=\"0\" cellSpacing=\"0\">"
."<TR>"
."<TD align=\"right\"><B> Request Date: </td>"
."<td align=\"left\">$date_required"
."</td>"
."</tr>"
."<TR>"
."<TD align=\"right\"><B> Dept/Location: </td>"
."<td align=\"left\">$dept_required"
."</td>"
."</tr>"
."<TR>"
."<TD align=\"right\"><B> Requested By: </td>"
."<td align=\"left\">$from_required"
."</td>"
."</tr>"
."<TR>"
."<TD align=\"right\"><B> E-mail address:nbsp</td>"
."<td align=\"left\">$email_required"
."</td>"
."</tr>"
."<TR>"
."<TD align=\"right\"><B> Phone: </td>"
."<td align=\"left\">$phone_required"
."</td>"
."</tr>"
."</BODY>"
."</TABLE>"
."<br><br><b>Item(s) requested:"
."</b><br><br>"
."<table border=\"2\" cellspacing=\"5\" cellpadding=\"2\">"
."<table border=\"2\" cellspacing=\"5\" cellpadding=\"2\">"
."<tr>"
."<th align=\"center\">Part Number"
."<th align=\"center\">Description"
."<th align=\"center\">Recommended Qty"
."<th align=\"center\">Qty Ordered"
."<tr>"
."<td align=\"left\">$pn"
."<td align=\"left\">$desc"
."<td align=\"left\">$rec"
."<td align=\"left\">$qty"
."</tr>"
for($i=1;$i<22;$i++) {
if($POST['qty'.$i] AND ($POST['pn'.$i] AND ($POST['desc'.$i] AND ($POST['rec'.$i])))) {
echo "<tr>"
."<td align=\"left\">".$_POST['pn'.$i]
."<td align=\"left\">".$_POST['desc'.$i]
."<td align=\"left\">".$_POST['rec'.$i]
."<td align=\"left\">".$_POST['qty'.$i];
}
}
."</table>"
."<br>"
."Comments:\n"
.$Comments
."</tr>" ,$headers);
if($mailed) {
echo "You have succesfully submitted your request";
}
?>
Thank you!!!
😕 😕