Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP while代码错误_Php_Error Handling_While Loop - Fatal编程技术网

PHP while代码错误

PHP while代码错误,php,error-handling,while-loop,Php,Error Handling,While Loop,使用函数代替mysqli\u fetch使用mysqli\u fetch\u数组代替mysqli\u fetch 此外,如果要在不使用索引的情况下获取,请使用mysqli\u fetch\u assoc(),表位于循环中 或 如果要使用索引获取,请使用mysqli\u fetch\u array() 我认为您在这里做错了,因为您的表标记在中,而循环和也在循环中。 我认为它应该在while循环之外。查询中有语法错误,还有一个额外的 你的完整代码 <?php $host="localhost

使用函数代替mysqli\u fetch

使用mysqli\u fetch\u数组代替mysqli\u fetch


此外,如果要在不使用索引的情况下获取,请使用mysqli\u fetch\u assoc(),表位于循环中

如果要使用索引获取,请使用
mysqli\u fetch\u array()

我认为您在这里做错了,因为您的表标记在
中,而
循环和
也在循环中。 我认为它应该在while循环之外。查询中有语法错误,还有一个额外的

你的完整代码

<?php 
$host="localhost";
$user="root";
$pwd="";
$db="assigment";
$conn=mysqli_connect($host,$user,$pwd,$db);
 $query="SELECT * FROM 'tdata'";
 $result=mysqli_query($conn,$query);
 while ($row=mysqli_fetch($result)) {

  ?>
   <table class="table">
        <thead>
        <tr>
            <th>Full Name</th>
            <th>Email</th>
            <th>Birthday</th>
            <th>Gender</th>
            <th>Intrests</th>
            <th>Address</th>
            <th></th>
        </thead>
        </tr>
        <tbody>
        <?php echo "<tr><td>".$row[full_name]."</td></tr>";
         }
         ?>

        </tbody>
    </table>

全名
电子邮件
生日
性别
兴趣
地址
<?php 
$host="localhost";
$user="root";
$pwd="";
$db="assigment";
$conn=mysqli_connect($host,$user,$pwd,$db);
 $query="SELECT * FROM tdata ";
 $result=mysqli_query($conn,$query); ?>
 <table class="table">
        <thead>
        <tr>
            <th>Full Name</th>
            <th>Email</th>
            <th>Birthday</th>
            <th>Gender</th>
            <th>Intrests</th>
            <th>Address</th>
        </tr>
        </thead>

        <tbody>
 <?php while ($row=mysqli_fetch_assoc($result)) { ?>

        <tr>
            <td><?php echo $row['full_name']; ?></td>
            <td><?php echo $row['your table field name']; ?></td>
            <td><?php echo $row['your table field name']; ?></td>
            <td><?php echo $row['your table field name']; ?></td>
            <td><?php echo $row['your table field name']; ?></td>
            <td><?php echo $row['your table field name']; ?></td>
        </tr>
        <?php }
         ?>
        </tbody>
    </table>