views/crud_view File in CodeIgniter 3
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>CRUD Operation in CodeIgniter</title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/bootstrap.min.css">
</head>
<body>
<div class="jumbotron">
<h1 align="center">CRUD CodeIgniter Application</h1>
</div>
<div class="container">
<div class="clear-fix">
<h3 style="float: left">All Products</h3>
<a href="#" class="btn btn-primary" style="float: right" data-bs-toggle="modal" data-bs-target="#exampleModal">Add Product</a>
</div>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Product Name</th>
<th>Product Price</th>
<th>Product Quantity</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($product_details as $products): ?>
<tr>
<td>
<?php echo $products->name; ?>
</td>
<td>
<?php echo $products->price; ?>
</td>
<td>
<?php echo $products->quantity; ?>
</td>
<td>
<a href="<?php echo base_url(); ?>Crud/editProduct/<?php echo $products->id; ?>" class="btn btn-success">Edit</a>
<a href="<?php echo base_url(); ?>Crud/deleteProduct/<?php echo $products->id; ?>" class="btn btn-danger">Delete</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form action="<?php echo base_url(); ?>Crud/addProduct" method="post">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Modal title</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="name">Name</label>
<?php echo form_error("name"); ?>
<input type="text" name="name" value="<?php echo set_value("name"); ?>" placeholder="Enter your name" class="form-control">
</div><br>
<div class="form-group">
<label for="price">Price</label>
<?php echo form_error("price"); ?>
<input type="text" name="price" value="<?php echo set_value("price"); ?>" placeholder="Enter your price" class="form-control">
</div><br>
<div class="form-group">
<label for="quantity">Quantity</label>
<?php echo form_error("quantity"); ?>
<input type="text" name="quantity" value="<?php echo set_value("quantity"); ?>" placeholder="Enter your quantity" class="form-control">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<input type="submit" name="insert" value="Add Product" class="btn btn-info">
</div>
</form>
</div>
</div>
</div>
<?php if ($this->session->flashdata("error")): ?>
<div align="center" style="color: #FFF" class="bg-danger">
<?php echo $this->session->flashdata("error"); ?>
</div>
<?php endif; ?>
<?php if ($this->session->flashdata("inserted")): ?>
<div align="center" style="color: #FFF" class="bg-success">
<?php echo $this->session->flashdata("inserted"); ?>
</div>
<?php endif; ?>
<?php if ($this->session->flashdata("updated")): ?>
<div align="center" style="color: #FFF" class="bg-success">
<?php echo $this->session->flashdata("updated"); ?>
</div>
<?php endif; ?>
<?php if ($this->session->flashdata("deleted")): ?>
<div align="center" style="color: #FFF" class="bg-success">
<?php echo $this->session->flashdata("deleted"); ?>
</div>
<?php endif; ?>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy" crossorigin="anonymous"></script>
</body>
.png)
.png)
.png)
.png)
.png)
.png)
.png)
.png)
.png)
Comments
Post a Comment