2013-08-03 71 views
0

我想要做的是, 我正在初始化邮件正文的$message变量。没有得到愿望输出

如果存在多个文件,我必须遍历循环。 那么我如何迭代循环并将值存储在变量中。

一样,

$message = "Dear " . $fname . " <br/>   
<b>Manuscript and Other Documents :</b> <br/> 
Source File : " .$file1 . " <br/> 
Source PDF File : ".$file2 . " <br/> 
Cover Letter : " . $file3 . "<br/> 
Supplementary Files : " . while($row=mysql_fetch_array($supplementary)){ echo $row[0] } . "; 

所以,我该怎么办,如果我有多个补充文件?

+0

使用字符串连接运算符点像$消息()。 =“....”,检查http://php.net/manual/en/language.operators.string.php – PravinS

+0

将您的supporant文​​件名分配给带有循环的变量,并将该变量附加到$ message,无论您身在何处想要它 –

回答

0

为此,只需使用string concatenation operator将数据附加到while循环内的消息变量即可。

例如:

$message = "Dear " . $fname . " <br/><b>Manuscript and Other Documents :</b><br/> 
Source File : " .$file1 . "<br/>Source PDF File : ".$file2 . " <br/> 
Cover Letter : " . $file3 . "<br/>Supplementary Files : "; 

while($row = mysql_fetch_array($supplementary)) { 
    $message .= echo $row[0] . '<br />'; 
} 
0

首先,这样做:

$suplArray = array(); 

while($row=mysql_fetch_array($supplementary)){ 
    $suplArray[] = $row[0]; 
} 

现在,你有一个数组中的字符串。我不知道你想要什么格式,但你可以这样做

$suplStr = implode(',', $suplArray); 

然后在你的字符串,你可以有:

... "Supplementary Files : " . $suplStr; 
+0

它只给出最后的文件名。 –

+0

然后**尝试调试它** ffs。你是代码的人。 – MightyPork