简体   繁体   English

用fwrite HTML创建PHP表

[英]PHP table creation in fwrite HTML

I have created an HTML form that passes information to a PHP file. 我创建了一个HTML表单,该表单将信息传递给PHP文件。

I have used fwrite to create an HTML file that includes variables from the form. 我使用fwrite创建了一个HTML文件,其中包含来自表单的变量。

In order to create a table I have this: 为了创建一个表,我有这个:

for($i = 0; $i < count($docresult); $i++){
echo "<tr><td>$i. </td><td><a href=\\docs\\\"$docresult[$i]\">$docresult[$i]</a></td><td>$txtresult[$i]</td><tr>";
}

What is best practice for placing this within a string? 将其放在字符串中的最佳实践是什么? Basically, I want this to work: 基本上,我想这样工作:

$DataToFwrite = "
    <table border=\"1\">
for($i = 0; $i < count($docresult); $i++){
echo "<tr><td>$i. </td><td><a href=\\docs\\\"$docresult[$i]\">$docresult[$i]</a></td><td>$txtresult[$i]</td><tr>";
}
    </table>";
fwrite($FileHolder, $DataToFwrite);

I have no idea how to do this! 我不知道该怎么做! I am new to PHP and would appreciate any help. 我是PHP新手,不胜感激。

I am not sure, try this one 我不确定,试试这个

$DataToFwrite = "<table border='1'>";
for($i = 0; $i < count($docresult); $i++){
    $href = "docs\\".$docresult[$i];
    $DataToFwrite .= "<tr><td>$i</td><td><a href='$href'>".$docresult[$i]."</a></td><td>".$txtresult[$i]."</td><tr>";
}
$DataToFwrite .= "</table>";
fwrite($FileHolder, $DataToFwrite);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM