如何分隔col4中的文件?

时间:2018-08-06 10:08:40

标签: php

如何在col4中分隔显示的文件?问题在于所有文件都显示在所有列中。

这是我的代码:

<?php
include 'connection.php';
$query="SELECT * from test2";
$result=mysqli_query($con, $query);
while ($row = mysqli_fetch_assoc($result)) {
$data[$row['id']] = array("col1" => $row['id'],"col2" => $row['name'],  
 "col3" => $row['email'],"col4" => $row['file']);
 }
$file=$_FILES['file'];
move_uploaded_file($file['tmp_name'], "Uploads/".$file['name']);
?>

<form action="#" method='post' enctype="multipart/form-data">
<input type="file" name="file" id="file"/><br><br>
<input type="submit" name="submit" value="Upload"/>
<table align="" border="1px solid black">
    <tr>
        <th>col4</th> 
        <th>col3</th> 
        <th>col2</th> 
        <th>col1</th>
    </tr>
     <?php
   foreach ($data as $i) { ?>
    /* here is the problem, all the files are displayed together */
        <td><?php
        $files=scandir("Uploads");
        for ($a=2; $a < count($files) ; $a++) { 
        ?>
        <a download="<?php echo $files[$a]?>" href="Uploads/<?php echo 
     $files[$a]?>"><?php echo $files[$a] ?>;</a>
        <?php
        }?></td>
       /* until here */
        <td> <?php echo $i['col3']; ?></td>
        <td> <?php echo $i['col2']; ?></td>
        <td> <?php echo $i['col1']; ?></td>
    </tr>
    <?php } ?>

1 个答案:

答案 0 :(得分:0)

只需在<br/>之后添加</a>

<a download="<?php echo $files[$a]?>" href="Uploads/<?php echo 
 $files[$a]?>"><?php echo $files[$a] ?>;</a><br/>