Tuesday, April 3, 2018

How to Select Data From MySQL Database Table Using PHP

PHP Code File:-

This program is about how to insert record into the database using html form.



<?php


$servername = "localhost";
$username = "root";
$password = "";
$dbname = "my_db";


$con = new mysqli($servername, $username, $password, $dbname);

if ($con->connect_error) {
    die("Connection failed: " . $con->connect_error);
}


$select= "select * from my_login";

$result = $con->query($select);


?>



HTML Code File:-



<table class="table m-0">

    <thead>

        <tr>

            <th>No</th>

            <th>First Name</th>

            <th>Last Name</th>

            <th>Username</th>

            <th>Action</th>

        </tr>

    </thead>

    <?php

 $i=1;

   
while($row = $result->fetch_assoc()) { ?>

        <tbody>

            <tr>

                <th scope="row">

                    <?php echo $i++; ?>

                </th>

                <td>

                    <?php echo $row["name"] ?>

                </td>

                <td>

                    <?php echo $row["email"] ?>

                </td>

                <td>

                    <?php echo $row["password"] ?>

                </td>

             

            </tr>

            <?php } ?>

        </tbody>

</table>

No comments:

Post a Comment

Generate Even Numbers in a Range In PHP.

$start = 1; $end = 20; for ($i = $start; $i <= $end; $i++) {     if ($i % 2 == 0) {         echo $i . " is even.<br>";   ...