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: <br></td><td class="text-info"><?php echo $row['Username'] ?></td></tr>
<tr class="input-lg"><td> Name: <br></td><td class="text-info"><?php echo $row['Name'] ?></td></tr>
<tr class="input-lg"><td> Password:<br></td><td class="text-info"><?php echo $row['Password'] ?></td></tr>
<tr class="input-lg"><td> Email:<br></td><td class="text-info"><?php echo $row['Email'] ?></td></tr>
<tr class="input-lg"><td> 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:
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.