I have total 7 Id in MySQL table. and I am fetching those Id's from database
code is :
<form class="form-inline" method="POST" action="book.php">
<div class="row-fluid home">
<div class="span3">
<?php
$query=mysql_query("select * from category");
$cat_count = 0;
while($result=mysql_fetch_array($query))
{
$category_id=$result['cat_id'];
$category_type=$result['cat_type'];
$categroy_desc=$result['cat_desc'];
$category_image=$result['cat_images'];
$category_price=$result['cat_price'];
$cat_count += 1;
//$_SESSION["session_category_id"] = $category_id;
?>
<div class="room_selector" data-price="<?php echo $category_price; ?>" data-adults="4" data-kids="2"
<?php if ($cat_count!=1) {echo 'style="display: none;"'; } ?> >
<h5>
<a href="index.php?id=<?php echo $category_id; ?>" class="pull-left">
<i class="icon-chevron-left"></i>
</a>
<?php echo $category_type; ?>
<a href="index.php?id=<?php echo $category_id; ?>" class="pull-right ">
<i class="icon-chevron-right"></i>
</a>
</h5>
<a class="iframe" href="rooms.php">
<img src="data:image/png;base64,<?php echo base64_encode($category_image); ?>" alt="No Photo" />
</a>
<p><?php echo $categroy_desc;?></p><br><Br><bR>
<!--<a class="btn btn-primary btn-large book-now" name="submit" type="submit" href="book.php?id=<?php echo $category_id; ?>">
Check Availability!</a>-->
<?php echo $x=$category_id;
?>
<input type="hidden" name="cat_id" value="<?php echo $category_id; ?>">
<?php $users[] = $result['cat_id'];?>
</div>
<?php
}
?>
<?php echo $category_id;
?>
</div>
<div class="span3 home_calendar">
<div class="form-horizontal">
<div class="control-group">
<label class="control-label pull-left" for="inputEmail">Arrive</label>
<div class="controls">
<input type="text" value="" name="from" class="span2 check-in-date" value="2015/05/22" />
</div>
</div>
</div>
<div class="datepicker_from"></div>
</div>
<div class="span3 home_calendar">
<div class="form-horizontal">
<div class="control-group">
<label class="control-label pull-left" for="inputEmail">Depart</label>
<div class="controls">
<input type="text" value="" name="to" class="span2 check-out-date" value="2015/05/27" />
</div>
</div>
</div>
<div class="datepicker_to"></div>
</div>
<div class="span3">
<div class="form-horizontal">
<div class="control-group">
<label class="control-label" for="inputEmail">Rooms</label>
<div class="controls">
<select class="span1 select_rooms" name="no_of_selected_room">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputEmail">Adults per room</label>
<div class="controls">
<select class="span1 select_adults" name="no_of_adults">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputEmail">Kids per room</label>
<div class="controls">
<select class="span1 select_kids" name="no_of_kids">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputEmail">extra person</label>
<div class="controls">
<select class="span1 select_kids">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</div>
</div>
</div>
<div id="total_price" class="price" name="price"></div>
<input type="submit" class="btn btn-primary btn-large book-now" name="submit" value="Check Availability!">
<!--<a class="btn btn-primary btn-large book-now" type="submit" href="book.php?id=">Check Availability!</a>-->
</div>
The $category_id is the main key to my project. once user will select the room then the $category_id will select based on that.
I am trying to send this id to other page using one form
//book.php
if(isset($_POST['submit']))
{
$n_cat_from = $_POST['from'];
$n_cat_to = $_POST['to'];
$n_no_of_selected_rooms = $_POST['no_of_selected_room'];
$n_no_of_adults = $_POST['no_of_adults'];
$n_no_of_kids = $_POST['no_of_kids'];
$current_Category_id = $_POST['cat_id'];
echo "id;;;;;;;;;;;;" . $current_Category_id;
}
?>
When I try to echo that id I am getting only last id in the database (after user selecting different id also )
where I am wrong ? why it is taking last Id ? help me
if you want to store multiple values in a hidden input with the same name, you have to add [] after the name, like this:
<input type="hidden" name="cat_id[]" value="<?php echo $category_id; ?>">
<?php $users[] = $result['cat_id'];?>
this way, you should have an array in book.php:
$_POST[cat_id] => Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 )
Related
I am trying to do a cubic calculator program where the calculated cubic meter is always added to the result of the previous calculation and displayed. I'm trying to do it with SESSION but it doesn't work out. When I start the calculation it does not show the value. How can I store the previous calculation and add it to the new one?
<?php
session_start();
include 'settings.php';
$title = 'Főoldal';
require_once 'components/htmltop.php';
require_once 'components/navbar.php';
if(isset($_POST["add_to_cart"]))
{
if(isset($_SESSION["cubic_cart"]))
{
$item_array = array(
'item_width' => $_POST["width"],
'item_length' => $_POST["length"],
'item_thickness' => $_POST["thickness"]
);
$_SESSION["cubic_cart"][0] = $item_array;
}
}
?>
<div class="col container text-center">
<div class="row">
<div class="col-sm">
<div class="container">
<form action="" method="post" class="col mx-auto mb-2 form-group p-3 text-center">
<div class="form-group col-md">
<input id="textBar" type="text" name="width" value="" class="i1 form-control mb-3 mx-auto" autocomplete="off" required>
</div>
<div class="row">
<div class="form-group col-md-6">
<select type="text" name="length" value="" class="s2 form-control mb-3 mx-auto" required>
<option selected>Length</option>
<option value="2.5">2.5</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
<div class="form-group col-md-6">
<select type="text" name="thickness" value="" class="s2 form-control mb-3 mx-auto" required>
<option selected>Thickness</option>
<option value="0.029">29</option>
<option value="0.031">31</option>
</select>
</div>
</div>
<button type="submit" name="add_to_cart" class="btn btn-lg btn-success" onclick="return confirm('Biztos rögzíteni szeretné?')">Calculate</button>
</form>
</div>
<div id="clockDisplay" class="container mb-2"></div>
<div claas="container">
<div class="row">
<div class="napi col-md-6 mt-3">
<?php
if(!empty($_SESSION["cubic_cart"]))
{
$total = 0;
foreach($_SESSION["cubic_cart"] as $keys => $values)
{
?>
<?php
$total = $total + ($values["item_width"] * $values["item_length"]* $values["item_thickness"]);
}
?>
?>
<h3>Total: </h3>
<h2><?php echo number_format($total, 4); ?> m3</h2>
<?php
}
?>
</div>
</div>
</div>
i have been making a crud application using php , mysql and bootstrap. everything is working fine but when i click on edit option the model does not open.i can understand why this is happening.
this is happening when i click on edit button. no modal is showing
Bootstrap modal not showing
code of edit button
<span class="glyphicon glyphicon-edit" style="color: #fff;"></span>
modal code
<div class="modal fade" id="edit<?php echo $row['userid']; ?>" role="dialog" aria-labelledby="myModalLabel" 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>
<center><h4 class="modal-title" id="myModalLabel">Edit</h4></center>
</div>
<div class="modal-body">
<?php
$edit=mysqli_query($conn,"select * from customer_record where userid='".$row['userid']."'");
$erow=mysqli_fetch_array($edit);
?>
<div class="container-fluid">
<form method="POST" action="edit.php?id=<?php echo $erow['userid']; ?>">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>NAME</label>
<input type="text" name="name" class="form-control" value="<?php echo $erow['name']; ?>">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>PHONE</label>
<input type="text" name="phone" class="form-control" value="<?php echo $erow['phone']; ?>" >
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>PRODUCT</label>
<input type="text" name="product" class="form-control" value="<?php echo $erow['product']; ?>" >
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>CLIENT NAME</label>
<select type="text" name="client" class="form-control" value="<?php echo $erow['client']; ?>">
<option>select</option>
<option> Carrefour FORT - L </option>
<option> Carrefour EMP - L </option>
<option> Carrefour PKJS - L </option>
<option> Carrefour LYPR - F </option>
<option> Carrefour WTC - I</option>
<option> Carrefour PAL - K</option>
<option> Carrefour L.ONE -K</option>
<option> Hyundai </option>
<option> Kenwood </option>
<option> Canon </option>
<option> Cash </option>
<option> Multynet </option>
<option> Panasonic</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>ADDRESS</label>
<input type="text" name="address" class="form-control" value="<?php echo $erow['address']; ?>">
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>ZONE AREA</label>
<select name="zone_area" class="form-control" value="<?php echo $erow['zone_area']; ?>">
<option>select</option>
<option>A</option>
<option>B</option>
<option>C</option>
<option>D</option>
<option>E</option>
<option>F</option>
<option>G</option>
<option>H</option>
<option>I</option>
<option>J</option>
<option>NA</option>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>DELIVERY DATE</label>
<input type="date" name="delivery_date" class="form-control" value="<?php echo $erow['delivery_date']; ?>">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>DELIVERY STATUS</label>
<select name="delivery_status" class="form-control" value="<?php echo $erow['delivery_status']; ?>">
<option>select</option>
<option> Self Carry </option>
<option> Pending </option>
<option> Lift Back</option>
<option> Deliverd</option>
<option> Deliverd in 2nd attempt</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>INVOICE #</label>
<input type="text" name="invoice" class="form-control" value="<?php echo $erow['invoice']; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>VEHICLE #</label>
<select type="text" name="vehicle" class="form-control" value="<?php echo $erow['vehicle']; ?>">
<option>select</option>
<option> RIN - 4546 </option>
<option> LES - 2200 </option>
<option> LES - 8732 </option>
<option> LES - 5884 </option>
<option> LES - 4964 </option>
<option> LES - 2150 </option>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>COUPAN #</label>
<input type="text" name="coupan" class="form-control" value="<?php echo $erow['coupan']; ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>INSTALLER NAME</label>
<input type="text" name="installername" class="form-control" value="<?php echo $erow['installername']; ?>">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>Installation Date</label>
<input type="date" name="installationdate" class="form-control" value="<?php echo $erow['installationdate']; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>INSTALLATION STATUS</label>
<select name="installationstatus" class="form-control" value="<?php echo $erow['installationstatus']; ?>">
<option>select</option>
<option>PROCESSED</option>
<option>COMPLETED</option>
<option>FAILED</option>
<option>Installed in 2nd Attempt</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Remarks ( Delivery + installation )</label>
<input type="text" id="remarks" name="remarks" class="form-control" value="<?php echo $erow['remarks']; ?>">
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
<button type="submit" class="btn btn-warning"><span class="glyphicon glyphicon-check"></span> Save</button>
</div>
</form>
</div>
</div>
</div>
the plugins i used
The following article is an answer to a similiar question, you might wanna take a look: https://stackoverflow.com/a/16095583/12739653
If it didn't help you. Please provide some general information; Did you import all required files, what's your Bootstrap version?
If you're using Bootstrap 5, you might need to use data-bs-target and data-bs-toggle instead. Learn more here: https://getbootstrap.com/docs/5.0/components/modal/#live-demo
Just make sure that your <div class="modal fade" ...> is inside the <body>.
There is problem in opening bootstrap modal in iphones.
If i use static modal like below,
<a href="#responsive" data-toggle="modal"><button class="btn btn-green ">Add Product<i class="fa fa-plus"></i></button>
</a>
<!-- start: BOOTSTRAP EXTENDED MODALS -->
<div id="responsive" class="modal extended-modal fade no-display">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
×
</button>
<h4 class="modal-title" style="color:red">Add New Product</h4>
</div>
<div class="modal-body">
<div class="row">
<form name="new" action="<?php echo base_url() ?>admin/addProduct" method="post" enctype="multipart/form-data" autocomplete="off">
<div class="col-md-6">
<h4><b>Category Name <span class="symbol required"></span></b></h4>
<p>
<select class="form-control" name="cat_id" required>
<option value="">---- Select Category ----</option>
<?php foreach($cat['list'] as $rows=>$value){ ?>
<option value="<?php echo $cat['list'][$rows]->cat_id; ?>"><?php echo ucwords($cat['list'][$rows]->cat_name); ?></option>
<?php } ?>
</select>
</p>
</div>
<div class="col-md-6">
<h4><b>Product Name <span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="item_name" required>
</p>
</div>
<div class="col-md-6">
<h4><b>Small Description <span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="small_desc">
</p>
</div>
<div class="col-md-6">
<h4><b>Quantity<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="number" name="quantity" required min="1">
</p>
</div>
<div class="col-md-6">
<h4><b>Customer Price<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="number" name="price" required min="1">
</p>
</div>
<div class="col-md-6">
<h4><b>Reseller Price<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="number" name="reseller" required min="1">
</p>
</div>
<div class="col-md-6">
<h4><b>Color<span class="symbol "></span></b></h4>
<p>
<input class="form-control" type="text" name="color">
</p>
</div>
<div class="col-md-6">
<h4><b>Availability <span class="symbol required"></span></b></h4>
<select class="form-control" name="availability">
<option value="1">Available</option>
<option value="0">Not Available</option>
</select>
</div>
<div class="col-md-6">
<h4><b>Image <span class="symbol required"></span></b></h4>
<p>
<input class="form-control" accept="image/*" onchange="loadFile(event)" type="file" name="userfile" required multiple>
<img id="output" width="100px" height="100px" />
</p>
</div>
</div>
</div>
<div class="modal-footer">
<button type="reset" data-dismiss="modal" class="btn btn-light-grey">
Close
</button>
<button type="submit" class="btn btn-blue">
Add Product
</button>
</div>
</form>
</div>
</div>
</div>
<!-- End Modal -->
the modal will open properly and i can enter values.
But if use the modal for editing like below,
<a href="#edit<?php echo $product['list'][$row]->item_id; ?>" data-toggle="modal">
<button class="btn btn-blue"><i class="fa fa-pencil"></i> Edit </button>
</a>
<div id="edit<?php echo $product['list'][$row]->item_id?>" class="modal extended-modal fade no-display">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
×
</button>
<h4 class="modal-title" style="color:red">Edit Product</h4>
</div>
<div class="modal-body">
<div class="row">
<form action="<?php echo base_url() ?>admin/editProduct" enctype="multipart/form-data" method="post" autocomplete="off">
<div class="col-md-6">
<h4><b>Category Name <span class="symbol required"></span></b></h4>
<p>
<select class="form-control" name="cat_id" required>
<option value="">---- Select Category ----</option>
<?php
foreach($cat['list'] as $rows=>$value){ ?>
<option value="<?php echo $cat['list'][$rows]->cat_id; ?>"<?php if($cat['list'][$rows]->cat_id == $product['list'][$row]->cat_id) echo "selected=selected"; ?>><?php echo ucwords($cat['list'][$rows]->cat_name); ?></option>
<?php } ?>
</select>
</p>
</div>
<div class="col-md-6">
<input type="hidden" name="item_id" value="<?php echo $product['list'][$row]->item_id;?>">
<input type="hidden" name="image_name" value="<?php echo $product['list'][$row]->image;?>">
<h4><b>Product Name <span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="item_name" value="<?php echo $product['list'][$row]->item_name;?>" required>
</p>
</div>
<div class="col-md-6">
<h4><b>Small Description <span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="small_desc" value="<?php echo $product['list'][$row]->small_desc;?>">
</p>
</div>
<div class="col-md-6">
<h4><b>Quantity<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="number" name="quantity" value="<?php echo $product['list'][$row]->quantity;?>" min="1" required>
</p>
</div>
<div class="col-md-6">
<h4><b>Customer Price<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="price" value="<?php echo $product['list'][$row]->price;?>" min="1" required>
</p>
</div>
<div class="col-md-6">
<h4><b>Reseller Price<span class="symbol required"></span></b></h4>
<p>
<input class="form-control" type="text" name="reseller" value="<?php echo $product['list'][$row]->reseller;?>" min="1" required>
</p>
</div>
<div class="col-md-6">
<h4><b>Color<span class="symbol"></span></b></h4>
<p>
<input class="form-control" type="text" name="color" value="<?php echo $product['list'][$row]->color;?>">
</p>
</div>
<div class="col-md-6">
<h4><b>Availability <span class="symbol required"></span></b></h4>
<select class="form-control" name="availability">
<?php if($product['list'][$row]->availability==1){;?>
<option value="1" selected>Available</option>
<option value="0">Not Available</option>
<?php } else {?>
<option value="1">Available</option>
<option value="0" selected>Not Available</option>
<?php }?>
</select>
</div>
<div class="col-md-6">
<h4><b>Status <span class="symbol required"></span></b></h4>
<select class="form-control" name="status">
<?php if($product['list'][$row]->status==0){;?>
<option value="0" selected>Inactive</option>
<option value="1">Active</option>
<?php } else {?>
<option value="0">Inactive</option>
<option value="1" selected>Active</option>
<?php }?>
</select>
</div>
<div class="col-md-6">
<h4><b>Image <span class=""></span>
</b></h4>
<input class="form-control" type="file" name="userfile">
<img src="<?php echo base_url()." assets/uploads/ ".$product['list'][$row]->image;?>" height="50px" width="50px" border="1px solid #FFF">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-light-grey">
Close
</button>
<button type="submit" class="btn btn-blue">
Update
</button>
</div>
</form>
</div>
</div>
</div>
With dynamic id, the modal will open with light black overlay on it. I can't edit the fields. Nothing is working inside the modal.
I am Not Understanding What is the problem with dynamic modal.
If Anyone knows Please reply.
You can try two things. 1. Move your form tag out and place it like this -
<form action="./admin/editProduct" enctype="multipart/form-data" method="post" autocomplete="off">
<div class="modal-body">
Give your modal z-index of 999 or so using css like this -
<style>
.modal {
z-index: 999;
}
</style>
here my html code.
i want fetch data from database. when a user search profile then i want display only searched data which enter in form.
the problem is query doesn't work. can you tell me can we run multiple query in single query.
<form method="get" action="search.php" enctype="multipart/form-data">
<div class="form_but1">
<label class="col-sm-2 control-lable1" for="sex">Gender : </label>
<div class="col-sm-7 form_radios">
<div class="select-block1">
<select name="gender">
<option value="">Select Gender</option>
<option value="">Male</option>
<option value="">Female</option>
</select>
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="form_but1">
<label class="col-sm-2 control-lable1" for="sex">Marital Status : </label>
<div class="col-sm-7 form_radios">
<div class="select-block1">
<select name="mstatus">
<option>Select status</option>
<option value="Single">Single</option>
<option value="Married">Married</option>
<option value="Widow">Widow</option>
<option value="Widower">Widower</option>
<option value="Divorcee">Divorcee</option>
<option value="Seprated">Seprated</option>
</select>
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="form_but1">
<label class="col-sm-2 control-lable1" for="sex">Gotra : </label>
<div class="col-sm-7 form_radios">
<div class="select-block1">
<select name="gotra">
<option>Select gotra</option>
<option value="Aalakuntor">Aalakuntor</option>
<option value="Bantalor">Bantalor</option>
<option value="Batalor">Batalor</option>
<option value="Bayamuttalor">Bayamuttalor</option>
</select>
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="form_but1">
<label class="col-sm-2 control-lable1" for="sex">District / City : </label>
<div class="col-sm-7 form_radios">
<div class="select-block1">
<input type="text" class="form-control" placeholder="city" name="city" >
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="form_but1">
<label class="col-sm-2 control-lable1" for="sex">Education : </label>
<div class="col-sm-7 form_radios">
<div class="select-block1">
<input type="text" class="form-control" placeholder="education" name="education" >
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="form_but1">
<label class="col-sm-2 control-lable1" for="sex">Age : </label>
<div class="col-sm-7 form_radios">
<div class="col-sm-5 input-group1">
<input class="form-control has-dark-background" name="age1" id="slider-name" placeholder="28" type="text" >
</div>
<div class="col-sm-5 input-group1">
<input class="form-control has-dark-background" name="age2" id="slider-name" placeholder="40" type="text" >
</div>
<div class="clearfix"> </div>
</div>
<div class="clearfix"> </div>
</div>
<div class="form_but1">
<div class="col-sm-5 input-group1">
<div class="select-block1">
<input type="submit" class="btn btn-success" value="Search" name="search">
</div>
</div>
<div class="clearfix"> </div>
</div>
</form>
here my search.php code.
<div class="paid_people">
<h1></h1>
<div class="row_1">
<?php
include("includes/db.php");
global $con;
if(isset($_GET['search']))
{
$search_gender = $_GET['gender'];
$search_mstatus = $_GET['mstatus'];
$search_gotra = $_GET['gotra'];
$search_city = $_GET['city'];
$search_education = $_GET['education'];
$search_age1 = $_GET['age1'];
$search_age2 = $_GET['age2'];
$get_user = "SELECT * FROM users WHERE age BETWEEN '$search_age1' AND '$search_age2' AND gender like '$search_gender' AND mstatus like '$search_mstatus' AND gotra like '$search_gotra' AND education like '$search_education' AND city like'$search_city'";
$run_user = mysqli_query($con, $get_user);
while ($row_user = mysqli_fetch_array($run_user))
{
$u_id = $row_user['user_id'];
$u_fname = $row_user['first_name'];
$u_age = $row_user['age'];
$u_education = $row_user['education'];
$u_occupation = $row_user['occupation'];
$u_city = $row_user['city'];
$u_image = $row_user['photo'];
$profile_id = $row_user['profile_id'];
echo "<div class='col-sm-6 paid_people-left'>
<ul class='profile_item'>
<a href='view_profile.php?userdetail_id=$u_id'>
<li class='profile_item-img'>
<img src='admin_vadarshadi/users-photo/resized_$u_image' class='img-responsive' alt='$u_fname' />
</li>
<li class='profile_item-desc'>
<h4>Profile ID: $profile_id</h4>
<h4>Name: $u_fname Age: $u_age Yrs </h4>
<p>City: $u_city, Education: $u_education</p>
<h5>View Full Profile</h5>
</li>
<div class='clearfix'> </div>
</a>
</ul>
</div>";
}
}
?>
</div>
</div>
I have this php code
<div class="form-group box">
<div class="col-lg-7">
<?php
foreach ($results as $row) {
echo '<select class="form-control" required name="article[]">
<option value="'.$row->articles_id.'">'.$row->article_name.'</option>';
$sql="SELECT * FROM articles WHERE article_active = 1";
$query = $this->db->query($sql);
$articles = $query->result();
foreach ($articles as $row){
echo'
<option value="'.$row->articles_id.'">'.$row->article_name.'</option>';
}
echo'</select>';
}
?>
</div>
<div class="col-lg-3">
<?php foreach ($results as $row) {
echo '<input class="form-control kolicina" type="text" value="'.$row->order_qty.'" name="qty[]" '.$disabled.' required/>'; }
?>
</div>
<div class="col-lg-2">
<?php foreach ($results as $row) {
echo'<button type="button" class="btn btn-danger button-remove">Remove</button>';
}
?>
</div>
</div>
When display this i got this HTML code
<div class="col-lg-7">
<select class="form-control" required="" name="article[]">
<option value="10">Cipiripi</option>
<option value="8">Koka Kola</option>
<option value="10">Cipiripi</option>
</select>
<select class="form-control" required="" name="article[]">
<option value="8">Koka Kola</option>
<option value="8">Koka Kola</option>
<option value="10">Cipiripi</option>
</select>
</div>
<div class="col-lg-3">
<input class="form-control kolicina" value="44" name="qty[]" required="" type="text">
<input class="form-control kolicina" value="44" name="qty[]" required="" type="text">
</div>
<div class="col-lg-2">
<button type="button" class="btn btn-danger button-remove">Remove</button>
<button type="button" class="btn btn-danger button-remove">Remove</button>
</div>
I have tried a lot ways with loop, to get proper code, this is example hos html should look?
<div class="form-group box">
<div class="col-lg-7">
<select class="form-control" required="" name="article[]">
<option value="10">Cipiripi</option>
<option value="8">Koka Kola</option>
<option value="10">Cipiripi</option>
</select>
</div>
<div class="col-lg-3">
<input class="form-control kolicina" value="44" name="qty[]" required="" type="text">
</div>
<div class="col-lg-2">
<button type="button" class="btn btn-danger button-remove">Remove</button>
</div>
</div>
<div class="form-group box">
<div class="col-lg-7">
<select class="form-control" required="" name="article[]">
<option value="8">Koka Kola</option>
<option value="8">Koka Kola</option>
<option value="10">Cipiripi</option>
</select>
</div>
<div class="col-lg-3">
<input class="form-control kolicina" value="44" name="qty[]" required="" type="text">
</div>
<div class="col-lg-2">
<button type="button" class="btn btn-danger button-remove">Remove</button>
</div>
</div>
What i need that loops goes in different wrapper, not in in same col?
This is working fiddle how it has to look
http://jsfiddle.net/ckqth4a7/
And this is what i have now
http://jsfiddle.net/q0njhgfk/
No, just ditch that inner foreach loops inside just build it by the whole row.
Something like:
<?php foreach($results as $row): ?> <!-- loop this as a whole row -->
<div class="form-group box">
<div class="col-lg-7">
<select class="form-control" required="" name="article[]">
<?php
// this is the only loop for the options inside the select
$sql = "SELECT * FROM articles WHERE article_active = 1";
$query = $this->db->query($sql);
$articles = $query->result();
?>
<?php foreach($articles as $article): ?>
<option value="<?php echo $article->articles_id; ?>"><?php echo $article->article_name; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-lg-3">
<input class="form-control kolicina" value="<?php echo $row->order_qty; ?>" name="qty[]" required="" type="text">
</div>
<div class="col-lg-2">
<button type="button" class="btn btn-danger button-remove">Remove</button>
</div>
</div>
<?php endforeach; ?>
Or maybe, if the query is just standing there and will not be dynamic take it off the parent loop.
<?php
// take this outside, its always the same anyway, so that it queries only once
// this is the only loop for the options inside the select
$sql = "SELECT * FROM articles WHERE article_active = 1";
$query = $this->db->query($sql);
$articles = $query->result();
?>
<?php foreach($results as $row): ?> <!-- loop this as a whole row -->
<div class="form-group box">
<div class="col-lg-7">
<select class="form-control" required="" name="article[]">
<?php foreach($articles as $article): ?>
<option value="<?php echo $article->articles_id; ?>"><?php echo $article->article_name; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-lg-3">
<input class="form-control kolicina" value="<?php echo $row->order_qty; ?>" name="qty[]" required="" type="text">
</div>
<div class="col-lg-2">
<button type="button" class="btn btn-danger button-remove">Remove</button>
</div>
</div>
<?php endforeach; ?>