php本机到codeigniter [关闭]

I have a problem with my native php. Can you give me tips? After I login how can I view details in database like name, email, gender, username through using codeigniter?

 <?php
$con=mysqli_connect("localhost","root","","enrollmentsystem");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
            
$result = mysqli_query($con,"SELECT * FROM admin where  Username='$username'");
            
while ($row = mysqli_fetch_array($result)) {
?>
<div class="table-responsive">
  <table class=" table-hover">
    <tr class="input-lg"><td>Username:&nbsp;&nbsp;&nbsp;<br></td><td class="text-info"><?php echo $row['Username'] ?></td></tr>
    <tr class="input-lg"><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Name:&nbsp;&nbsp;&nbsp;<br></td><td class="text-info"><?php echo $row['Name'] ?></td></tr>
    <tr class="input-lg"><td>&nbsp;Password:<br></td><td class="text-info"><?php echo $row['Password'] ?></td></tr>
    <tr class="input-lg"><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Email:<br></td><td class="text-info"><?php echo $row['Email'] ?></td></tr>
    <tr class="input-lg"><td>&nbsp;&nbsp;&nbsp;&nbsp;Gender:<br></td><td class="text-info"><?php echo $row['Gender'] ?></td></tr>
  </table>
</div>
<?php
}
            
mysqli_close($con);
?>

</div>

A few points before I begin:

  1. CodeIgniter has a built in MySQL querying class. Your current implementation of querying is prone to MySQL injection. Read more...
  2. Using the above query builder, you can get the results in many forms. Read more...
  3. You should query the database in a model, and pass the data to the view. Read more about MVC here..., and read more about passing data to views here...
  4. You should definitely start with the tutorial here which explains how to do something similar to what you want as well as other things to get you started.

However, if you wish to continue as it is, here are some things I noticed:

In:

while($row = mysqli_fetch_array($result))
              {

$row = mysqli_fetch_array($result) does return a truthy value, but there is no code changing the query, so the server gets stuck in an infinite loop.

Next, in:

$result = mysqli_query($con,"SELECT * FROM admin where  Username='$username'"); 

$username does not seem to be assigned. Im assuming it is assigned before the view is sent to the client?

Try fixing these and see if it works as you intend it to.