twitter bootstrap - PHP loop not working inside of modal -
i have button opens modal , button inside of function.
function gallery_full() { ///some code above $lisos='<button type="button" class="btn-red btn-xs btn btn-default" data-toggle="modal" data-target="#lisos'.$number.'" style="background-color:#cf000f; color:white; margin-right:-10px; "><span class="glyphicon glyphicon-info-sign"></span> cores lisas</button>'; ///some code below }
as can see in data-target have variable called $number , defined in function.
i created modal inside of function, working content of modal should looping , displaying products,but not. showing wrong product, each product in db has row called number_ , contains number 1-0, 1-1, 1-2, 2-0 , on.
my modal inside of loop need other loop inside of it. because want products contains same number_
value of $number
can pass $number variable first function function?
this first function
my modal code
<?php function modal_color(){ global $conn; $get_color = "select * gallery2 number_='$number'"; /// $number not defined here,but on other funtion $run_color = mysqli_query($conn,$get_color); while ($rows = mysqli_fetch_assoc($run_color)){ $id=$rows['id'] ; //some html code <span class="label label-info center-block" style="background-color:#cf000f;">liso '.$number.'</span <a id="carousel-selector-0" ><img src="../'.$rows['image'].'" ></a> //some html code <button type="button" class="btn btn-primary actions add btn-block " data-action="add" product_id="'.$id.'" > </span> add</button> //some closing divs '; } $sql = "select * gallery2 liso = 1 "; $run = mysqli_query($conn,$sql); while ($rows = mysqli_fetch_assoc($run)){ $vari = $rows['variante']; $num = $rows['title']; $isliso = $rows['liso']; $id=$rows['id']; if($vari< 1){ $dash=""; $vari=""; }else{ $dash="-"; $vari = $rows['variante']; } $dashcol="-"; $varii = $rows['variante']; $number=$num.$dashcol.$varii; //number defined here echo '<div class="modal fade" id="lisos'.$number.'" role="dialog"> //some html tags of modal <div class="btn-group pull-right"> <button type="button" class="btn btn-default pull-right" data-dismiss="modal" aria-hidden="true">×</button> </div> <h3 class="modal-title">'.$num.''.$dash.''.$vari.'</h3> </div> <div class="modal-body"> <div class="col-md-12"> '.$color.' ///////// trying loop </div> //ending modal tags ';}} ?>
Comments
Post a Comment