如何在MySQL中打印整个表

时间:2015-10-12 04:20:20

标签: php html mysql

目前我有这个代码显示MySQL数据库中的所有表格但是当试图打印它时不打印整个表但只显示一行请帮助任何人导致它在while循环中

$handle = fopen($_FILES['filename']['tmp_name'], "r");

while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
    $import="INSERT into info(tazkira,gender,province,category,clin,training) values('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]')";

    mysql_query($import) or die(mysql_error());
}

fclose($handle);

print "Import done";

1 个答案:

答案 0 :(得分:0)

正如Niranjan所说,您应该将表标记移动到while循环之外。

       <table width="1900px"  cellspacing="2px" cellpadding="2px">
   <?php while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
    {
    ?>
    <!-- Main Content -->
        <tr>
            <th class="box" scope="col"> <?php echo " " .$row['student_id']; ?></th>
            <th class="name" scope="col"><?php echo "  " .$row['student_name']; ?></th>
            <th class="subject"scope="col"><?php echo " " .$row['kannada']; ?></th>
            <th class="subject"scope="col"><?php echo " " .$row['english']; ?></th>
            <th class="subject"scope="col"><?php echo "" .$row['hindi']; ?></th>
            <th class="subject"scope="col"><?php echo " " .$row['maths']; ?></th>
            <th class="subject"scope="col"><?php echo " " .$row['science']; ?></th>
            <th class="subject"scope="col"><?php echo " " .$row['social']; ?></th>
            <th class="result-exam" scope="col"><?php echo " " .$row['result']; ?></th>
            <th  class="result-exam" scope="col"><?php echo " " .$row['test']; ?></th>
            <th  class="result-exam" scope="col"><?php echo " " .$row['date']; ?></th>
        </tr>

    <?php }?>
    </table>
</div>