How to delete row with PDO and with restriction - php

I have two tables in mysql database, the first one is 'kavomati' where are coffee machines and second table is 'lokacije' where are locations of those coffee machines and that tables have relations with primary key in database and it is set ON DELETE RESTRICT so I can't delete some location which have coffee machine and that's good. I created one page where I see all locations and there I have modal button for add new location, modal buttons for edit each location and at the end of each address I added delete modal button for each row. What I want to do is to delete every location which has no coffee machine but first I must make a query in php and check is certain location have any coffee machine. I'm newbie in php so I would appreciate any help.
This is my code to display locations of my database table and modal buttons:
<?php
if(!isset($_SESSION['user_id'])){
header('Location: ../../index.php');
}
try{
$stmt = $conn->prepare('SELECT id,ulica,kc_broj,mjesto FROM lokacije ORDER BY id ASC');
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
catch(PDOException $e){
if(DEBUG === true){
header('Location:error/db_error.php?err_msg='.$e->getMessage());
}
else{
header('Location:error/db_error.php?err_msg');
}
}
?>
<div class="panel-heading clearfix">
<h3 style="float:left; margin:0;">Lokacije</h3>
Dodaj lokaciju
</div>
<table class="table table-hover">
<tr>
<th>ID</th>
<th>Ulica</th>
<th>Kućni broj</th>
<th>Mjesto</th>
<th></th>
</tr>
<?php
foreach($data as $value){
?>
<tr>
<td>
<?php echo $value['id'].'.'?>
</td>
<td>
<?php echo $value['ulica']?>
</td>
<td>
<?php echo $value['kc_broj']?>
</td>
<td>
<?php echo $value['mjesto']?>
</td>
<td align="right">
<a href="#" data-toggle="modal" data-target="#edit_loc<?php echo $value['id']?>" role="button" class="btn btn-success btn-sm edit">
<i class="fa fa-pencil-square-o"></i> Uredi
</a>
<div class="modal fade edit-u" id="edit_loc<?php echo $value['id']?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content" style="text-align:left;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Uredi lokaciju broj <?php echo $value['id']?></h4>
</div>
<form action="" method="POST">
<div class="modal-body">
<input type="hidden" name="id_lokacije" id="id_lokacije" value="<?php echo $value['id']?>">
<div class="form-group ulica">
<label for="ulica">Ulica</label>
<input type="text" class="form-control" name="ulica" id="ulica-u" placeholder="Ostavite prazno polje ako ne želite mjenjati naziv kavomata" value="">
</div>
<div class="form-group kc_broj">
<label for="kc_broj">Kućni broj</label>
<input type="text" class="form-control" name="kc_broj" id="kc_broj-u" placeholder="Ostavite prazno polje ako ne želite mjenjati naziv kavomata" value="">
</div>
<div class="form-group mjesto">
<label for="mjesto">Mjesto</label>
<input type="text" class="form-control" name="mjesto" id="mjesto-u" placeholder="Ostavite prazno polje ako ne želite mjenjati naziv kavomata" value="">
</div>
</div>
</form>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Zatvori</button>
<button type="button" class="btn btn-primary" id="edit_loc">Spremi</button>
</div>
</div>
</div>
</div>
<a href="#" data-toggle="modal" data-target="#delete_loc<?php echo $value['id']?>" role="button" class="btn btn-danger btn-sm">
<i class="fa fa-trash-o"></i> Izbriši
</a>
<div class="modal fade" id="delete_loc<?php echo $value['id']?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content" style="text-align:center;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h2 class="modal-title" id="myModalLabel" style="color:#a80b27;text-transform:uppercase;font-size:1.6rem;">upozorenje !</h2>
</div>
<div class="modal-body">
<h5>Da li si siguran da želiš obrisati lokaciju broj <b><?php echo $value['id']?></b>?</h5>
</div>
<div class="modal-footer">
<a href="include/locations/delete.php?id=<?php echo $value['id']?>" role="button" class="btn btn-danger">
Da, siguran sam!
</a>
<button type="button" class="btn btn-default" data-dismiss="modal">Ne</button>
</div>
</div>
</div>
</div>
</td>
</tr>
<?php
}
?>
</table>
<div class="modal fade" id="add_locModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Dodaj novu lokaciju</h4>
</div>
<form action="" method="POST">
<div class="modal-body">
<div class="form-group ulica">
<label for="ulica">Ulica</label>
<input type="text" class="form-control" name="ulica" id="ulica" placeholder="Ulica">
</div>
<div class="form-group kc_broj">
<label for="kc_broj">Kućni broj</label>
<input type="text" class="form-control" name="kc_broj" id="kc_broj" placeholder="Kućni broj">
</div>
<div class="form-group mjesto">
<label for="mjesto">Mjesto</label>
<input type="text" class="form-control" name="mjesto" id="mjesto" placeholder="Mjesto">
</div>
</div>
</form>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Zatvori</button>
<button type="button" class="btn btn-primary" id="add_loc">Dodaj</button>
</div>
</div>
</div>
And this is my delete.php script:
require '../../config/init.php';
require '../services/xss.php';
if(isset($_SESSION['user_id']) && isset($_GET['id'])){
$id = $_GET['id'];
try{
$stmt = $conn->prepare('DELETE FROM lokacije WHERE id=:id NOT IN(SELECT k.id FROM kavomati k WHERE k.id=lokacije.id)');
$stmt->bindParam(':id',$id);
$stmt->execute();
header('Location:../../coffee-locations.php');
}
catch(PDOException $e){
if(DEBUG === true){
header('Location:../../error/db_error.php?err_msg='.$e->getMessage());
}
else{
header('Location:../../error/db_error.php?err_msg');
}
}
}
else{
header('Location:../../index.php');
}
?>
I tried something like this but it doesn't work.Please help.

It shouldn't work as well since your query syntax is total wrong. It should be
DELETE FROM lokacije
WHERE id NOT IN(SELECT id FROM kavomati)

Related

how to summarize loop on modal bootstrap 4 edit/delete? in php codeigniter 3

**how to summarize loop on modal bootstrap 4 edit/delete in php codeigniter 3 **
because if you use a loop on the modal, it will make the website slow
<?php foreach ($foto as $f) { ?>
<form action="<?= base_url() . 'admin/foto/delete' ?>" method="post" enctype="multipart/form-data">
<div class="modal fade" id="modal-hapus<?= $f->id_foto; ?>" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-primary">
<h4 class="modal-title">Hapus Data</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body justify-content-center">
<div class="text-center">
<img class="mt-2 mb-2" src="<?= base_url(); ?>assets/dist/icon/hapus.svg" width=80% alt="delete-img">
<h4 class="mb-4">Apakah anda yakin untuk menghapus file dari <b><?= $f->judul_foto ?></b> ini?</h4>
</div>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Tutup</button>
<input type="hidden" name="id_hapus" value="<?= $f->id_foto; ?>" required>
<button type="submit" class="btn btn-danger"><i class="fas fa-trash"></i> Hapus</button>
</div>
</div>
</div>
</div>
</form>

How do I retrieve data display in modal

First Image to show all data in card view
second image for pop up modal
What I want is when I clicked the View button, it will get all the data and display in the modal. The data can be display in the inputbox, textarea and image.
This is the code to row all the data in a card view
<?php
while ($row = mysqli_fetch_assoc($result)){
$wid = $row['web_id'];
?>
<div class="col-sm-4 col-xs-12">
<div class="panel panel-default text-center">
<div class="panel-heading">
<h3><b><?php echo $row['web_name']; ?></b></h3>
</div>
<div class="panel-body">
<?php
if(empty($row['web_image'])){
echo "<span class='no-image glyphicon glyphicon-picture'></span><br><b>NO IMAGE AVAILABLE</b>";
}else{
echo "<div class='imageContainer'><img src='images/".$row['web_image']. "'width='50%' height='15%'/></div>";
}
?>
</div>
<div class="panel-footer">
<h4><b><?php echo $row['web_id']; ?></b></h4>
<a target="_blank" href="<?php echo $row['web_address']; ?>"><h4><?php echo $row['web_address'];?></h4></a>
<h4><?php echo $row['web_description']; ?></h4>
<hr>
//This is an button for view modal
<?php echo '<button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#viewmodal" class="viewbtn">View</button>'; ?>
<?php echo '<button class="btn1 btn-sm"><span class="glyphicon glyphicon-edit"></span> EDIT</button>';?>
</div>
</div>
</div>
<?php
}
?>
This is the modal code
<!--View Modal pop up-->
<div class="modal fade" id="viewmodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" >
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h3 class="modal-title" id="exampleModalLabel"><b>VIEW DATA</b></h3>
</div>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
<div class="modal-body">
<div class="form-group">
<label><b>Web ID : </b></label> <span class="validation">*</span>
<input name="w_id" id="w_id" value="" type="text" class="form-control input-box" readonly>
</div>
<div class="form-group">
<label><b>Web Name : </b></label> <span class="validation">*</span>
<input name="w_name" id="w_name" type="text" class="form-control input-box" required>
</div>
<div class="form-group">
<label><b>Web Address : </b></label> <span class="validation">*</span>
<input name="w_address" id="w_address" type="text" class="form-control input-box" required></input>
</div>
<div class="form-group">
<label><b>Web Description : </b></label> <span class="validation">*</span>
<input name="w_description" id="w_description" type="text" class="form-control input-box" required></input>
</div>
<div class="form-group">
<label><b>Web Image : </b></label> <span class="validation">*</span>
<img src='images/".$row["web_image"]. "'width='333px;' height='200px;' name="w_image" id="w_image"/>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="save" class="btn btn-primary">SAVE</button>
<button type="button" name="close" class="btn btn-warning" data-dismiss="modal">CLOSE</button>
</div>
</form>
</div>
</div>
</div>
As i can see you are looping through the panel and you have only one modal in there, what you can do is use data property and JS/Jquery combination to do this.
<?php
while ($row = mysqli_fetch_assoc($result)){
$wid = $row['web_id'];
?>
<div class="col-sm-4 col-xs-12">
<div class="panel panel-default text-center">
<div class="panel-heading">
<h3><b><?php echo $row['web_name']; ?></b></h3>
</div>
<div class="panel-body">
<?php
if(empty($row['web_image'])){
echo "<span class='no-image glyphicon glyphicon-picture'></span><br><b>NO IMAGE AVAILABLE</b>";
}else{
echo "<div class='imageContainer'><img src='images/".$row['web_image']. "'width='50%' height='15%'/></div>";
}
?>
</div>
<div class="panel-footer">
<h4><b><?php echo $row['web_id']; ?></b></h4>
<a target="_blank" href="<?php echo $row['web_address']; ?>"><h4><?php echo $row['web_address'];?></h4></a>
<h4><?php echo $row['web_description']; ?></h4>
<hr>
//This is an button for view modal
<?php echo '<button type="button" class="btn btn-success btn-sm" data-img="<?=$row['img']?>" class="viewbtn">View</button>'; ?>
<?php echo '<button class="btn1 btn-sm"><span class="glyphicon glyphicon-edit"></span> EDIT</button>';?>
</div>
</div>
</div>
<?php
}
?>
<!--View Modal pop up-->
<div class="modal fade" id="viewmodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" >
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h3 class="modal-title" id="exampleModalLabel"><b>VIEW DATA</b></h3>
</div>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
<div class="modal-body">
<div class="form-group">
<label><b>Web Image : </b></label> <span class="validation">*</span>
<img width='333px;' height='200px;' name="w_image" id="w_image"/>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="save" class="btn btn-primary">SAVE</button>
<button type="button" name="close" class="btn btn-warning" data-dismiss="modal">CLOSE</button>
</div>
</form>
</div>
</div>
</div>
Now a little bit of jQuery to assign values in the modal fields and open the modal,when view button is clicked
$(function(){
$(".viewbtn").click(function(){
var img = $(this).data("img")
$("#w_image").attr("src",img)
$("#viewmodal").modal()
})
})
So, this is the basic idea of it, you can add other data props and assign the values to the fields accordingly

Modal Bootstrap - Always delete the last image and not the selected image i want

In the site that I am developing, I want to delete the selected image, but it always deletes the last image and not the chosen image. Can someone solve this problem? Thank you!
All the code in this link
https://pastebin.com/tpQnMwfY
<div class="col-sm-6 col-md-4 col-lg-2">
<br>
<div id="imagem_galeria"><a class="fancybox" href="upload/bairro_galeria/<?php echo $row['imagee']; ?>" data-fancybox-group="gallery"><img src="upload/bairro_galeria/<?php echo $row['imagee']; ?>" class="image-responsive"></a></div>
<br>
<div class="row">
<div class="col-sm-6" align="right"><a href="admin_bairro_galeria_editar?update_id=<?php echo $row['id']; ?>" class="btn btn-warning btn-sm custom-btn" >Editar</a></div>
<div class="col-sm-6" >Eliminar
<div class="modal fade" id="exampleModal2" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Pretende mesmo eliminar?</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-warning custom-btn" data-dismiss="modal">Cancelar</button>
<a href="?delete_id2=<?php echo $row['id']; ?>" class="btn btn-danger custom-btn" >Eliminar</a>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<br>
</div>

Delete button for each row with restriction

I have two tables in mysql database, the first one is 'kavomati' where are coffee machines and second table is 'lokacije' where are locations of those coffee machines. I created one page where I see all locations and there I have modal button for add new location, modal buttons for edit each location and at the end of each address I added delete modal button for each row. What I want to do is to delete every location which has no coffee machine but first I must make a query in php and check is certain location have any coffee machine. I'm newbie in php and this is my homework problem so I would appreciate any help.
This is my code to display locations of my database table and modal buttons:
<?php
if(!isset($_SESSION['user_id'])){
header('Location: ../../index.php');
}
try{
$stmt = $conn->prepare('SELECT id,ulica,kc_broj,mjesto FROM lokacije ORDER BY id ASC');
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
catch(PDOException $e){
if(DEBUG === true){
header('Location:error/db_error.php?err_msg='.$e->getMessage());
}
else{
header('Location:error/db_error.php?err_msg');
}
}
?>
<div class="panel-heading clearfix">
<h3 style="float:left; margin:0;">Lokacije</h3>
Dodaj lokaciju
</div>
<table class="table table-hover">
<tr>
<th>ID</th>
<th>Ulica</th>
<th>Kućni broj</th>
<th>Mjesto</th>
<th></th>
</tr>
<?php
foreach($data as $value){
?>
<tr>
<td>
<?php echo $value['id'].'.'?>
</td>
<td>
<?php echo $value['ulica']?>
</td>
<td>
<?php echo $value['kc_broj']?>
</td>
<td>
<?php echo $value['mjesto']?>
</td>
<td align="right">
<a href="#" data-toggle="modal" data-target="#edit_loc<?php echo $value['id']?>" role="button" class="btn btn-success btn-sm edit">
<i class="fa fa-pencil-square-o"></i> Uredi
</a>
<div class="modal fade edit-u" id="edit_loc<?php echo $value['id']?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content" style="text-align:left;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Uredi lokaciju broj <?php echo $value['id']?></h4>
</div>
<form action="" method="POST">
<div class="modal-body">
<input type="hidden" name="id_lokacije" id="id_lokacije" value="<?php echo $value['id']?>">
<div class="form-group ulica">
<label for="ulica">Ulica</label>
<input type="text" class="form-control" name="ulica" id="ulica-u" placeholder="Ostavite prazno polje ako ne želite mjenjati naziv kavomata" value="">
</div>
<div class="form-group kc_broj">
<label for="kc_broj">Kućni broj</label>
<input type="text" class="form-control" name="kc_broj" id="kc_broj-u" placeholder="Ostavite prazno polje ako ne želite mjenjati naziv kavomata" value="">
</div>
<div class="form-group mjesto">
<label for="mjesto">Mjesto</label>
<input type="text" class="form-control" name="mjesto" id="mjesto-u" placeholder="Ostavite prazno polje ako ne želite mjenjati naziv kavomata" value="">
</div>
</div>
</form>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Zatvori</button>
<button type="button" class="btn btn-primary" id="edit_loc">Spremi</button>
</div>
</div>
</div>
</div>
<a href="#" data-toggle="modal" data-target="#delete_loc<?php echo $value['id']?>" role="button" class="btn btn-danger btn-sm">
<i class="fa fa-trash-o"></i> Izbriši
</a>
<div class="modal fade" id="delete_loc<?php echo $value['id']?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content" style="text-align:center;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h2 class="modal-title" id="myModalLabel" style="color:#a80b27;text-transform:uppercase;font-size:1.6rem;">upozorenje !</h2>
</div>
<div class="modal-body">
<h5>Da li si siguran da želiš obrisati lokaciju broj <b><?php echo $value['id']?></b>?</h5>
</div>
<div class="modal-footer">
<a href="include/locations/delete.php?id=<?php echo $value['id']?>" role="button" class="btn btn-danger">
Da, siguran sam!
</a>
<button type="button" class="btn btn-default" data-dismiss="modal">Ne</button>
</div>
</div>
</div>
</div>
</td>
</tr>
<?php
}
?>
</table>
<div class="modal fade" id="add_locModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Dodaj novu lokaciju</h4>
</div>
<form action="" method="POST">
<div class="modal-body">
<div class="form-group ulica">
<label for="ulica">Ulica</label>
<input type="text" class="form-control" name="ulica" id="ulica" placeholder="Ulica">
</div>
<div class="form-group kc_broj">
<label for="kc_broj">Kućni broj</label>
<input type="text" class="form-control" name="kc_broj" id="kc_broj" placeholder="Kućni broj">
</div>
<div class="form-group mjesto">
<label for="mjesto">Mjesto</label>
<input type="text" class="form-control" name="mjesto" id="mjesto" placeholder="Mjesto">
</div>
</div>
</form>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Zatvori</button>
<button type="button" class="btn btn-primary" id="add_loc">Dodaj</button>
</div>
</div>
</div>
And this is my delete.php script:
require '../../config/init.php';
require '../services/xss.php';
if(isset($_SESSION['user_id']) && isset($_GET['id'])){
$id = $_GET['id'];
try{
$stmt = $conn->prepare('DELETE FROM lokacije WHERE id=:id NOT IN(SELECT k.id FROM kavomati k WHERE k.id=lokacije.id)');
$stmt->bindParam(':id',$id);
$stmt->execute();
header('Location:../../coffee-locations.php');
}
catch(PDOException $e){
if(DEBUG === true){
header('Location:../../error/db_error.php?err_msg='.$e->getMessage());
}
else{
header('Location:../../error/db_error.php?err_msg');
}
}
}
else{
header('Location:../../index.php');
}
?>
I tried something like this but it doesn't work.

How to display a popup when clicks the link in the header?

In my header provide a link for adding new client. When click the add client link display a popup window that contain a textbox and a submit button.When i click the link display popup window fully fade in(shaded) and not display the label
Whats wrong here?
header
<a data-hover="dropdown" data-close-others="true" data-toggle="modal" class="dropdown-toggle" href="#addClientPop" <?php if($home_index== 1) { ?> class="active" <?php } ?>></span>
Add Client<span class="arrow"></span>
</a>
<div id="addClientPop" class="modal hide fade" tabindex="-1" data-width="760">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h3>Add Client</h3>
</div>
<div class="modal-body">
<div class="scroller" style="height:75px" data-always-visible="1" data-rail-visible1="1">
<div class="row-fluid">
<div class="control-group">
<label class="control-label">Client Name</label>
<div class="controls">
<input id="client_name" name="client_name" class="client_box" type="text" class="form-control" required >
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button onClick="submit_client();" type="button" class="btn blue">Submit</button>
</div>
</div>
This is your solution i have worked well
<a data-hover="dropdown" data-close-others="true" data-toggle="modal" class="dropdown-toggle active" href="#addClientPop" >
Add Client<span class="arrow"></span>
</a>
<div id="addClientPop" class="modal fade" tabindex="-1" aria-hidden="true">
<div class="modal-dialog ">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h3>Add Client</h3>
</div>
<div class="modal-body">
<div class="scroller" style="height:75px" data-always-visible="1" data-rail-visible1="1">
<div class="row-fluid">
<div class="control-group">
<label class="control-label">Client Name</label>
<div class="controls">
<input id="client_name" name="client_name" class="client_box" type="text" class="form-control" required >
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button onClick="submit_client();" type="button" class="btn blue">Submit</button>
</div>
</div>
</div>
</div>
In your code what i have noticed that you have closed </span> tag in <a> and if($home_index==1) then class attribute is going to be add two times.
It should be like:
<a data-hover="dropdown" data-close-others="true" data-toggle="modal" class="dropdown-toggle <?php if($home_index== 1) { echo 'active';}?>" href="#addClientPop">Add Client <span class="fa fa-arrow-down"></span> </a>
<li>
<a data-hover="dropdown" data-close-others="true" data-toggle="modal" class="dropdown-toggle active" href="#addPop" >
Add Client<span class="arrow"></span>
</a>
<div id="addPop" class="modal fade" tabindex="-1" aria-hidden="true">
<div class="modal-dialog ">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h3>Add Client</h3>
</div>
<div class="modal-body">
<div class="scroller" style="height:75px" data-always-visible="1" data-rail-visible1="1">
<div class="row-fluid">
<div class="control-group">
<label class="control-label">Client Name</label>
<div class="controls">
<input id="market_price" name="market_price" class="client_box" type="text" class="form-control" required >
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button onClick="submit_price();" type="button" class="btn blue">Submit</button>
</div>
</div>
</div>
</div>
</li>

Categories