Database file
after download, follow my instructions...
how to install the datavase file in mysql.
1. create database name as filename into database name.
2. export the .sql file or run & excute the query.
3. that's all.
1. Database Connection
<?php $mysqli= new mysqli('localhost','root','','crud') or die(mysqli_error($mysqli)); ?>
2. Includes PHP Files
<?php require_once 'FileName.php'; ?>
3. View the table information
<?php
$result= $mysqli->query("SELECT * FROM data") or die(mysqli_error($mysqli));
pre_r($result);
?>
<?php
function pre_r($array)
{
echo '<pre>';
print_r($array);
echo '</pre>';
}
?>
4. View the data of table one by one
<?php
$mysqli= new mysqli('localhost','root','','crud') or die(mysqli_error($mysqli));
$result= $mysqli->query("SELECT * FROM data") or die(mysqli_error($mysqli));
// We have listed out 3 raws in data table
pre_r($result->fetch_assoc());
pre_r($result->fetch_assoc());
pre_r($result->fetch_assoc());
?>
<?php
function pre_r($array)
{
echo '<pre>';
print_r($array);
echo '</pre>';
}
?>
5. How to view the data in table format
<?php
$result= $mysqli->query("SELECT * FROM data") or die(mysqli_error($mysqli));
?>
<div class="row justify-content-center">
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Location</th>
<th clospan="2">Action</th>
</tr>
<tbody>
//Starting while loop
<?php while ($row = $result->fetch_assoc()): ?>
<tr>
<td><?php echo $row['name'];?></td>
<td><?php echo $row['location'];?></td>
</tr>
//End of the while loop
<?php endwhile; ?>
</tbody>
</thead>
</table>
</div>
No comments:
Post a Comment