如何修复While循环输出结果

时间:2019-01-25 13:20:43

标签: php css

我只想获取在PHP中不同行中的while循环的结果

    if($count == 0){
        $output = 'THERE WAS NO RESULTS';
    }
    else{
        while($row = mysqli_fetch_array($query)){       
            $des = $row['description'];
            $file = $row['name'];

            $output ='<div>'.$des. '</div>';
            echo "<td>";
            echo "$output";
            echo "<a href='".$file."'>Download</a></td>";
        }
    }
}

echo "</table>";
?>

我在同一行中得到所有结果。

1 个答案:

答案 0 :(得分:0)

您是否缺少表格行标记? <tr>

    if($count == 0){
            $output = 'THERE WAS NO RESULTS';
        }
        else{
          echo '<table>';
            while($row = mysqli_fetch_array($query)){       
                $des = $row['description'];
                $file = $row['name'];

                echo '<tr>';
                echo '<td><div>'. $des .'</div></td>';
                echo '<td><a href='".$file."'>Download</a></td>';
                echo '</tr>';
            }
          echo '</table>';
        }