-1
<?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>

Error# Fatal error: Uncaught Error: Call to undefined function mysqli_fetch() in C:\xampp\htdocs\gsoft\assigment\tabledb.php:9 Stack trace: #0 {main} thrown in C:\xampp\htdocs\gsoft\assigment\tabledb.php on line 9

Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
Lucky
  • 9
  • 1
  • 5
  • Possible duplicate of [mysqli fetch\_all() not a valid function?](https://stackoverflow.com/questions/6694437/mysqli-fetch-all-not-a-valid-function) – Isaac Martin Otim Apr 28 '18 at 05:05
  • Possible duplicate of [Where do I need to use backticks or quotes in my MYSQL query?](https://stackoverflow.com/questions/8704587/where-do-i-need-to-use-backticks-or-quotes-in-my-mysql-query) – mickmackusa Apr 28 '18 at 05:27

3 Answers3

0

use mysqli_fetch_array function instead of mysqli_fetch

Mayank Majithia
  • 1,916
  • 16
  • 21
0

Use mysqli_fetch_array instead of mysqli_fetch

Also your table is inside the loop

Rp9
  • 1,955
  • 2
  • 23
  • 31
0

if you want fetch without index use mysqli_fetch_assoc().

Or

if you want to fetch with index use mysqli_fetch_array()

And i think you are doing wrong here because your table tag is inside while loop and your <thead> too. i think it should be outside of while loop. and you have syntax error in your query and you have one extra <th>

your full code.

<?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>
Rahul
  • 1,617
  • 1
  • 9
  • 18