Hacked By AnonymousFox
<div class="col-md-12">
<?php
if(isset($_POST['add']))
{
$parent_id = $_POST['parent_id'];
$name = $_POST['name'];
$sqlSubject=mysqli_query ($cn, "insert into `tbl_city` set parent_id='$parent_id',name='$name'");
if ($sqlSubject){
echo '<div class="alert alert-success"><strong>Success!</strong> City Page Added Successfully.</div>';
}
else
{
echo '<div class="alert alert-danger"><strong>Danger!</strong> City Page Not Exist.</div>';
}
}
if(isset($_POST['edit']))
{
$id = $_POST['id'];
$parent_id = $_POST['parent_id'];
$name = $_POST['name'];
$sql = mysqli_query($cn, "select * from tbl_city where id='$id'");
$sqlData = mysqli_fetch_array($sql);
$sqlSubject = mysqli_query ($cn,"update tbl_city SET parent_id='$parent_id',name='$name' where `id`='$id'");
if($sqlSubject)
{
echo '<div class="alert alert-success"><strong>Success!</strong> City Page Update Successfully.</div>';
}
else
{
echo '<div class="alert alert-success"><strong>Warrning!</strong> Not Updated try again.</div>';
}
}
if(isset($_GET['edit_id']))
{
$id = $_GET['edit_id'];
$sql = mysqli_query($cn, "select * from tbl_city where id='$id'");
$sqlData = mysqli_fetch_array ($sql);
}
if(isset($_GET['delete_id']))
{
$id = $_GET['delete_id'];
$sql = mysqli_query($cn, "delete from tbl_city where id='$id'");
if($sql)
{
echo '<div class="alert alert-success"><strong>Success!</strong> City Page Deleted Successfully.</div>';
}
else
{
echo "error: " . $sql . "<br>" . mysqli_error($conn);
}
}
?>
</div>
<div class="col-md-12">
<div class="card">
<div class="card-body">
<h4 style="margin-bottom:25px;">Add City</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">State Page</label>
<select class="form-control" id="exampleFormControlSelect1" name="parent_id" required>
<option value="">Select State</option>
<?php
$sqlState = mysqli_query($cn, "select * from `tbl_state`");
while($sqlStateData = mysqli_fetch_array($sqlState)){?>
<option value="<?php echo $sqlStateData['id'];?>" <?php if(isset($_GET['edit_id'])){ if($sqlData['parent_id']==$sqlStateData['id']){ echo "selected";}}?>><?php echo $sqlStateData['name'];?></option>
<?php }?>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="exampleInputPassword4">City Name</label>
<input type="text" class="form-control" name="name" value="<?php if(isset($_GET['edit_id'])) {echo $sqlData['name'];}?>">
<input type="hidden" class="form-control" name="id" value="<?php if(isset($_GET['edit_id'])) {echo $sqlData['id'];}?>">
</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">City List</h4>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Sr. No.</th>
<th>State Page Name</th>
<th>City Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
$sqlCity = mysqli_query($cn, "select * from `tbl_city`");
while($sqlCityData = mysqli_fetch_array($sqlCity)){
$sqlParent = mysqli_query($cn, "select * from `tbl_state` where id='".$sqlCityData['parent_id']."'");
$sqlParentData = mysqli_fetch_array($sqlParent);
?>
<tr>
<td><?php echo $i++;?></td>
<td><?php echo $sqlParentData['name'];?></td>
<td><?php echo $sqlCityData['name'];?></td>
<td><a href="home.php?pages=city&edit_id=<?php echo $sqlCityData['id'];?>">Edit</a> | <a href="home.php?pages=city&delete_id=<?php echo $sqlCityData['id'];?>" onclick="return deleteConfirm();">Delete</a></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
Hacked By AnonymousFox1.0, Coded By AnonymousFox