File "currencyMaster.php"
Full Path: /home/krishnamexports/public_html/panel/pages/sub_category/currencyMaster.php
File size: 5.75 KB
MIME-type: text/x-php; charset=us-ascii
Charset: utf-8
<?php
if(isset($_POST['add']))
{
$name = mysqli_real_escape_string($cn,$_POST['name']);
$amount = $_POST['amount'];
$title = mysqli_real_escape_string($cn,$_POST['title']);
$currency_symbol = mysqli_real_escape_string($cn,$_POST['currency_symbol']);
$sqlSubject = mysqli_query ($cn, "insert into `tbl_currency` set `name`='".$name."', `value`='".$amount."', `title`='".$title."', `currency_symbol`='".$currency_symbol."'");
if ($sqlSubject)
{
echo '<div class="alert alert-success"><strong>Success!</strong> Currency Added Successfully.</div>';
}
else
{
echo '<div class="alert alert-danger"><strong>Danger!</strong> Currency Not Added. Try Again.</div>';
}
}
if(isset($_POST['edit']))
{
$id = $_POST['id'];
$name = mysqli_real_escape_string($cn,$_POST['name']);
$amount = $_POST['amount'];
$title = mysqli_real_escape_string($cn,$_POST['title']);
$currency_symbol = mysqli_real_escape_string($cn,$_POST['currency_symbol']);
$sqlSubject = mysqli_query ($cn,"update `tbl_currency` set `name`='".$name."', `value`='".$amount."', `title`='".$title."', `currency_symbol`='".$currency_symbol."' where `id`='$id'");
if($sqlSubject)
{
echo '<div class="alert alert-success"><strong>Success!</strong> Currency Update Successfully.</div>';
}
else
{
echo '<div class="alert alert-success"><strong>Warrning!</strong> Currency Not Updated. Try again.</div>';
}
}
if(isset($_GET['edit_id']))
{
$id = $_GET['edit_id'];
$sql = mysqli_query($cn, "select * from `tbl_currency` where id='$id'");
$sqlData = mysqli_fetch_array ($sql);
}
?>
<div class="col-md-12">
<div class="card">
<div class="card-body">
<h4 style="margin-bottom:25px;">Currency Master</h4>
<form class="forms-sample" method="post" enctype="multipart/form-data">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label for="exampleInputPassword4">Currency Name</label>
<input type="hidden" class="form-control" name="id" value="<?php if(isset($_GET['edit_id'])) {echo $sqlData['id'];}?>">
<input type="text" class="form-control" name="name" value="<?php if(isset($_GET['edit_id'])) {echo $sqlData['name'];}?>">
<p>Ex. Like USD, EURO Etc.</p>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="exampleInputPassword4">Currency Amount</label>
<input type="text" class="form-control" name="amount" value="<?php if(isset($_GET['edit_id'])) {echo $sqlData['value'];}?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="exampleInputPassword4">Currency Symbol</label>
<textarea class="form-control" name="currency_symbol" cols="1" required><?php if(isset($_GET['edit_id'])) {echo $sqlData['currency_symbol'];}?></textarea>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label for="exampleInputPassword4">Currency Title</label>
<textarea class="form-control" name="title" cols="1" required><?php if(isset($_GET['edit_id'])) {echo $sqlData['title'];}?></textarea>
</div>
</div>
</div>
<button type="submit" class="btn btn-success mr-2" name="<?php if(isset($_GET['edit_id'])) {echo "edit";}else{ echo "add";}?>">Submit</button>
</form>
</div>
</div>
</div>
<div class="col-md-12">
<div class="card">
<div class="card-body">
<h4 class="card-title">Currency List</h4>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Sr. No.</th>
<th>Name</th>
<th>Amount</th>
<th>Title</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
$sqlCity = mysqli_query($cn, "select * from `tbl_currency` order by `id`");
while($sqlCityData = mysqli_fetch_array($sqlCity)){
?>
<tr>
<td><?php echo $i++;?></td>
<td><?php echo $sqlCityData['name'];?></td>
<td><?php echo $sqlCityData['value'];?></td>
<td><?php echo $sqlCityData['title'];?></td>
<td><a href="home.php?pages=currencyMaster&edit_id=<?php echo $sqlCityData['id'];?>">Edit</a></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>