Jump to content

Recommended Posts

I am new in PHP Programming , Please Help me.

I have made a data table, then i have connected this table after that  I have made a table in my index.php file . but i am facing problem to show data from data table in my index.php file, can you help me to solve this problem?

 

<?php include "db.php"; ?>

<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

    <title>Post Global Variable</title>
</head>

<body>

    <div class="row p-5">
        <table class="table table-dark">
            <thead>
                <tr>
                    <th scope="col">#</th>
                    <th scope="col">Name</th>
                    <th scope="col">User Name</th>
                    <th scope="col">Email Address</th>
                    <th scope="col">Password</th>
                    <th scope="col">Phone</th>
                    <th scope="col">Join Date</th>
                    <th scope="col">Action</th>
                </tr>
            </thead>
            <tbody>


                <?php
            
            $myQuery = "SELECT * FROM users";
            $allUsers = mysqli_query ($db, $myQuery);
      
            while ($row = mysqli_fetch_assoc($allUsers)){
                
                $id= $row['id'];
                $name= $row['name'];
                $userName= $row['userName'];
                $email= $row['email'];
                $password= $row['password'];
                $phone= $row['phone'];
                $join_date= $row['join_date'];
                
               
                ?>

                <tr>
                    <th scope="row"><?php echo $id; ?></th>
                    <td><?php echo $name; ?></td>
                    <td><?php echo $userName; ?></td>
                    <td><?php echo $email; ?></td>
                    <td><?php echo $password; ?></td>
                    <td><?php echo $phone; ?></td>
                    <td><?php echo $join_date; ?></td>
                    <td><a class="btn btn-success btn-sm" href="#" role="button">Update</a>
                        <a class="btn btn-danger btn-sm" href="#" role="button">Delete</a>
                    </td>
                </tr>

                <?php
                
            }
      
        ?>

            </tbody>
        </table>
    </div>



    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>

</html>

 

Edited by MH90
Link to comment
https://forums.phpfreaks.com/topic/310183-php-database-data-fetch-problem/
Share on other sites

As a newbie I highly recommend reading up on the "heredocs" use in the PHP manual.  It will save you a lot of work when outputting your html table rows by avoiding having to switch in and out of php mode for every var.

Still don't know what you "problem" is tho.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.