I have this code:
foreach ($images as $key => $value)
{
$items[$key]['weight'] = $value['fid'].'_'.$value['weight'] ;
$items[$key]['image'] = ''.image_load($value['uri'],array("class"=>"img-thumbnail","thumbs"=>"medium")).'' ;
$items[$key]['title'] = '<span id="title_file_'.$value['fid'].'">'.$value['title'].'</span>' ;
//$cover = "<a href='javascript:void(0);' onclick='javascript:gallery_cover(\"".$value['fid']."\"); return false;' id='gallery_cover_".$value['fid']."' data-toggle='tooltip' class='data-tooltip' data-placement='top' data-original-title='Top' id='tooltip1'><span class='btn btn-default btn-sm glyphicon glyphicon-eye-".(isset($gallery_cover['value']) && $gallery_cover['value']==$value['fid']?'open':'close')."'></span></a>" ;
$edit = "<a href='javascript:void(0);' onclick='javascript:update_file(\"".$value['fid']."\"); return false;' class='btn btn-info' data-toggle='tooltip' class='data-tooltip' data-placement='top' data-original-title='Modifier' id='tooltip1'>Modifier</a>" ;
$delete = "<a href='javascript:void(0);' onclick='javascript:delete_added_image(\"".$value['fid'].'_'.$value['weight']."\"); return false;' class='btn btn-default' data-toggle='tooltip' class='data-tooltip' data-placement='top' data-original-title='Supprimer' id='tooltip1'>Supprimer</a>" ;
$items[$key]['actions'] = $edit." ".$delete ;
}
foreach($images as $key => $value)
{
if ($key % 4 == 0)
echo "<div class=\"row\">" ;
echo "<div class=\"col-md-3\">" ;
echo "<div class='thumbnail' style='min-height:280px;height:280px;'>".$items[$key]['image'] ."
<div>
<h4 style='min-height:50px;'>".$items[$key]['title']."</h4>
<p>".$items[$key]['actions']."</p>
</div>
</div>" ;
echo "</div>" ;
}
the result :
I want every thumbnais to have a fixed button and title.
Any solution for that ?
Thanks
Really, you should create thumbnails of specific dimensions then this would never be an issue. If however you can't/wont/whatever, then try some css:
<style>
.crop {
width: 200px;
height: 150px;
overflow: hidden;
}
.crop img {
width: 300px;
height: 225px;
margin: -75px 0 0 -100px;
}
</style>
<div class="crop"><img src="1.jpg"></div>
<div class="crop"><img src="2.jpg"></div>
This will resize and crop.
Good luck :)
Related
form{
display: flex;
flex-flow: row wrap;
justify-content: space-between;
align-items: center;
align-content: space-around;
}
form .buttons{
width: 100%;
border: none;
background-color: #ffffff00;
cursor: pointer;
}
form .buttons img{
width: 100%;
}
form button{
width: 100%;
border: none;
color: #fff;
background-color: #000000;
}
I'm a rookie in bootstrap for starter. The thing is I have ten buttons which contain image, but depending on an if statement, not all the button will be displayed. My problem is to display the remaining button 3 per row responsively using bootstrap or css.
I have used tables, flexbox, grid but it still can't do it.
echo "</head>";
echo"<body>";
echo "<script src=\"../js/jquery.js\"></script>";
echo "<form action='../include/newHealthScore.php' method='post'>";
echo "<input type='text' name='input1' id='input1' value='' hidden='true'>
<input type='text' name='input2' id='input2' value='' hidden='true'>
<input type='text' name='input3' id='input3' value='' hidden='true'>";
echo "<div class = 'container'>";
echo "<div class = 'col-md-12'>";
echo "<div class=\"jumbotron jumbotron-fluid\">
<div class=\"container\" align=\"center\">
<h1 class=\"display-4\">Choose a maximum of 3 options</h1>
<p class=\"lead\" align=\"justify\">Depending on your health score calculated, some option will be available for you to choose. Each option will give you points so as to increase your overall health score. Point for blood pressure is displayed in pink. Point for LDL is displayed in yellow. Point for HDL is displayed in blue. Point for HbA1c is displayed in orange. Point for waist is displayed in green. Finally point for whether you smoke or not is displayed in brown.</p>
</div>
</div>";
echo "</div>";
echo "</div>";
echo "<div class = 'container'>";
echo "<div class='d-inline-flex'>";
if( $bPressure < 10)
{
echo "<div class=\"p-2\">";
echo "<button class='buttons' value='activity1' type='button'><img src='../img/salt.png'></button><br/>";
}
if($bPressure < 10 || $ldl < 10 || $hdl < 10 || $hba1c < 10 || $waist < 10)
{
echo "<div class=\"p-2\">";
echo "<button class='buttons' value='activity2' type='button' ><img src='../img/balancemeal.png'></button><br/>";
echo "</div>";
}
if ($bPressure < 10 || $ldl < 10 || $hba1c < 10 || $waist < 10)
{
echo "<div class=\"p-2\">";
echo "<button class='buttons' value='activity3' type='button'><img src='../img/rawveg.png'></button><br/>";
echo "</div>";
}
if($hdl < 10 || $ldl < 10 || $hba1c < 10 || $waist < 10)
{
echo "<div class=\"p-2\">";
echo "<button class='buttons' value='activity4' type='button'><img src='../img/fat.png'></button><br/>";
echo "</div>";
}
if($ldl < 10 || $hba1c < 10 || $waist < 10)
{
echo "<div class=\"p-2\">";
echo "<button class='buttons' value='activity5' type='button'><img src='../img/sugar.png'></button><br/>";
echo "</div>";
}
if($bPressure < 10 || $hdl < 10 || $hba1c < 10 || $waist < 10)
{
echo "<div class=\"p-2\">";
echo "<button class='buttons' value='activity6' type='button'><img src='../img/alcohol.png'></button><br/>";
echo "</div>";
}
if($bPressure < 10 || $ldl < 10 || $hdl < 10 || $hba1c < 10 || $waist < 10 || $smoke < 10)
{
echo "<div class=\"p-2\">";
echo "<button class='buttons' value='activity7' type='button'><img src='../img/30min.png'></button><br/>";
echo "</div>";
}
if($bPressure < 10 || $ldl < 10 || $hdl < 10 || $hba1c < 10 || $smoke < 10)
{
echo "<div class=\"p-2\">";
echo "<button class='buttons' value='activity8' type='button'><img src='../img/walk303.png'></button><br/>";
echo "</div>";
}
if($smoke < 10)
{
echo "<div class=\"p-2\">";
echo "<button class='buttons' value='activity9' type='button'><img src='../img/smoking.png'></button><br/>";
echo "</div>";
}
if($takePill = "y")
{
echo "<div class=\"p-2\">";
echo "<button class='buttons' value='activity10' type='button'><img src='../img/pills.png'></button>";
echo "</div>";
}
echo "<div class= 'd-flex justify-content-center'>";
echo "<input class = 'btn btn-primary rounded-pill btm-lg btn-huge' type='submit' name='Submit' value = 'Submit'/>";
echo "</div>";
echo "</form>";
echo "</div>";
echo "</div>";
echo "<script src=\"https://code.jquery.com/jquery-3.4.1.slim.min.js\"></script>
<script src=\"https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js\" ></script>
<script src=\"https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js\" ></script>
";
echo "</body>";
[enter image description here][1]
I found a way to do it. but now new problem arises. They are glued together and now i can't put a space between them. Also they do not fill up the container.
Bellow is the new code
<!-- begin snippet: js hide: false console: true babel: false -->
Simply by using grid system of Bootstrap. You can have div with container and if you want to have a full-width container the div has to have a container-fluid class then for each line of buttons you need make a div with a class of row and put your button -in this case three buttons- in every row inside divs with col classes and give a css class called btn-block to every button like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
crossorigin="anonymous"
/>
<title>Having three buttons per row in Bootstrap 4.4.1</title>
</head>
<body>
<div class="container-fluid">
<div class="row m-2">
<div class="col">
<button type="button" class="btn btn-primary m-1 btn-block">btn 1</button>
</div>
<div class="col">
<button type="button" class="btn btn-primary m-1 btn-block">btn 2</button>
</div>
<div class="col">
<button type="button" class="btn btn-primary m-1 btn-block">btn 3</button>
</div>
</div>
<div class="row m-2">
<div class="col">
<button type="button" class="btn btn-secondary m-1 btn-block">btn 1</button>
</div>
<div class="col">
<button type="button" class="btn btn-secondary m-1 btn-block">btn 2</button>
</div>
<div class="col">
<button type="button" class="btn btn-secondary m-1 btn-block">btn 3</button>
</div>
</div>
</div>
<script
src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
crossorigin="anonymous"
></script>
<script
src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"
></script>
<script
src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"
></script>
</body>
</html>
And in case you need a btn-group you can use them instead of normal btn and you can read more about it from related Bootstrap documentation for btn-group.
I am trying to open a new tab with a specific url with variables on it but the variables are not passed on the second tab. please help me with this . Heres my code.
<?php
$type= $_GET['type'];
$brochure_id = $_GET['id'];
$sql1 = "SELECT * from business_type WHERE business_id = '$type'";
$q1= $conn->query($sql1);
$q1->setFetchMode (PDO::FETCH_ASSOC);
$location=" ";
while($r1 = $q1->fetch())
{
if($r1['business_type'] == "Hotel"){
$location ="hotel.php";
}
else if($r1['business_type'] == "Restaurant"){
$location ="restaurant.php";
}
else if($r1['business_type'] == "Resort"){
$location ="resort.php";
}
else if($r1['business_type'] == "Spa"){
$location ="spa.php";
}
else if($r1['business_type'] == "Entertainment"){
$location ="entertainment.php";
}
}
echo "<a href='search-result-page-" . $location . "'?id='" . $brochure_id ."'' target='_blank' style='text-decoration: none' >
<div style='width: 260px; min-height: 30px; background-color: rgba(180,180,180,0.5); position: absolute; z-index: 1000; font-size: 17px; padding: 5px; color: black'>" . $r['business_name'] . "</div>
<img src='". $r['display_pic'] ."' width='260px' height='150px' />
</a>
</td>";
if($maxcol==$column){
echo "</tr>";
$column=0;
}
}
?>
I have created following pagination (see image);
here I want to display "Next>>" and "Last" at the end of 28. I cannot change the code to achieve that order because I am using if else block in my PHP code;
Here is the code part;
echo "<ul class='pagination'>";
echo "Page: $page of $last <br>";
echo "Record count: ". $rec_count. "<br>";
echo "Left count: ". $left_rec. "<br>";
echo "Record limit: ". $rec_limit. "<br>";
if( ($page==1) && ($left_rec>0) ){ //this is first page
echo '<li> Next >> <br> </li>';
echo "<li> Last </li>";
}
else if( ($page>1) && ($left_rec>0) ){
echo "<li> First <br> </li>";
echo '<li> << Previous <br> </li>';
echo '<li> Next >> <br> </li>';
echo "<li> Last </li>";
}
else if( ($page>1) && ($left_rec<$rec_limit) ){
echo "<li> First </li>";
echo '<li> << Previous <br> </li>';
}
/* Displaying page numbers (optional) */
for( $i=1; $i<=$last; $i++ ){
if( $i==$page ){
echo "<li> <a class=\"current\" href=\"{$_SERVER['PHP_SELF']}?page=$i\"> $i </a> </li>";
}
else{
echo "<li> $i </li>";
}
}
echo "</ul>";
How can I achieve that using CSS? I have my CSS used so far:
<style>
ul.pagination{
text-align:center;
color:#829994;
}
ul.pagination li{
display:inline;
padding: 0px 3px; /* here we cannot specify padding for top and bottom because inline display does not support margins and
paddings top and bottom*/
}
ul.pagination a{
color:#0d7963;
display:inline-block;
border:1px solid #cde0dc;
margin:3px 0;
padding:5px 10px;
text-decoration: none;
}
ul.pagination a:hover,
ul.pagination a.current{
background:#0d7963;
color:#fff;
}
</style>
I have some code which I want to display like this:
Posts and and the comments on those posts.
I want to echo "all the comments"; if a post has atleast one comment else echo "no comments".
Below is my code which doesnt work in terms of the if else statement and the divs. Thanks for your help.
The codes starts from the while loop.Rest works fine:
while($row=mysql_fetch_array($query)){
$fname =$row['fname'];
$sname=$row['sname'];
$id=$row['poster_id'];
$id2=$row['commenter_id'];
$email=$row['email'];
$profile_pic=$row['profile_pic'];
$city=$row['city'];
$country=$row['country'];
$search_date=$row['search_date'];
$QUERY=$row['QUERY'];
$search_id=$row['search_id'];
$comment=$row['comment'];
//-displays the result of the array
echo "<div style='border-radius: 25px; border: 1px solid #73AD21; padding: 20px; width: 90%;'> ".'<img src="'.htmlentities($row["poster_photo"], ENT_QUOTES, 'UTF-8').'" alt="Avatar" style="max-width:50px;max-height:50px;" />'." ".$row["poster_fname"]. " ".$row["poster_sname"]." around <span style='color:#04B486;'>".$row["poster_city"]." </span>in <span style='color:green;'>".$row["poster_country"]." </span> </span> on <span style='color:blue;'>".$row["search_date"]." </span><div style='margin-left:8%;'> I am looking for <span style='color:green;'>".$row["QUERY"]." </div></span> </br><span class='metoo'>            <a href='#' data-toggle='tooltip' data-placement='top' title='Click this if you also need similar assistance!'><img src='images/icons/meetoo.png' alt='me too' style='width:20px;height:20px;'></a><a href='#' data-toggle='tooltip' data-placement='top' title='Click this if you also need similar assistance!'>Me too</a>         <a href='#' data-toggle='tooltip' data-placement='top' title='Click this to direct a friend!'><img src='images/icons/advise.png' alt='advise' style='width:20px;height:20px;'></a><a href='#' data-toggle='tooltip' data-placement='top' title='Click this to direct a friend!'>Advise</a>        <a href=\"user.php?id=$id\" data-toggle='tooltip' data-placement='top' title='Click this if you will sort out this issue 100%!'><img src='images/icons/assist.png' alt='me too' style='width:15px;height:15px;'></a> <a href=\"user.php?id=$id\" data-toggle='tooltip' data-placement='top' title='Click this if you will sort out this issue 100%!'>Assist</a>           </span> </br> </br>
<?php if ($comment !== 'NULL'){
echo '<div style='margin-left:35%; font-size:80%'> <center><u style='font-size:75%;'><strong> Advises </strong> </u></center></br> ".'<img src="'.htmlentities($row["commenter_photo"], ENT_QUOTES, 'UTF-8').'" alt="Avatar" style="max-width:50px;max-height:50px;" />'." ".$row["commenter_fname"]. " ".$row["commenter_sname"]." said: <span style='color:blue;'>".$row["comment"]." </span><span style='margin-left:8%;'> on <span style='color:green;'>".$row["comment_date"]." </span></span> </br>;'
}else {
echo 'Nothing to show';
}
?>
</div>
</div>
</br>";
}
?>
Here is the proper format to concatenate in PHP
<?php
while($row=mysql_fetch_array($query))
{
$id=$row['poster_id'];
$id2=$row['commenter_id'];
echo '<div style="float:left"><img src="'.htmlentities($row["poster_photo"], ENT_QUOTES, 'UTF-8').'">';
if ($comment !== 'NULL')
{
echo '<div style="float:left"><img src="'.htmlentities($row["commenter_photo"], ENT_QUOTES, 'UTF-8').'">';
}
else
{
echo 'Nothing to show';
}
echo '</div>';
echo '</div>' ;
echo '</br>' ;
}
?>
Can you try in this below format,
<?php
while($row=mysql_fetch_array($query)){
echo "<div style='border-radius: 25px; border: 1px solid #73AD21; padding: 20px; width: 90%;'>";
echo "<a href='user.php?id=".$id."'>";
echo "<img src='".htmlentities($row["poster_photo"], ENT_QUOTES, 'UTF-8')."' alt='Avatar' style='max-width:50px;max-height:50px;' />";
...
....
...
if ($comment !== 'NULL'){
echo "<div style='margin-left:35%; font-size:80%'> <center><u style='font-size:75%;'><strong> Advises </strong> </u></center></br> ";
echo "<a href='user.php?id=".$id2."'>";
echo "<img src='".htmlentities($row["commenter_photo"], ENT_QUOTES, 'UTF-8')."' alt='Avatar' style='max-width:50px;max-height:50px;' />".$row["commenter_fname"]. " ".$row["commenter_sname"]." </a> said: <span style='color:blue;'>".$row["comment"]."</span><span style='margin-left:8%;'> on <span style='color:green;'>".$row["comment_date"]." </span></span> </br>";
}else {
echo 'Nothing to show';
}
echo "</div></div></br>";
}
?>
Hope it may help you.
Just formatted your code, but you still need to check quotes (") or ('), that they are managed properly.
echo "<div style='border-radius: 25px; border: 1px solid #73AD21; padding: 20px; width: 90%;'>
<a href=\"user.php?id=$id\">".'
<img src="'.htmlentities($row["poster_photo"], ENT_QUOTES, 'UTF-8').'" alt="Avatar" style="max-width:50px;max-height:50px;" />'." ".$row["poster_fname"]. " ".$row["poster_sname"]."
</a> around
<span style='color:#04B486;'>".$row["poster_city"]." </span>
in <span style='color:green;'>".$row["poster_country"]." </span>
on <span style='color:blue;'>".$row["search_date"]." </span>
<div style='margin-left:8%;'> I am looking for
<span style='color:green;'>".$row["QUERY"]." </span>
</div>
</br>
<span class='metoo'>           
<a href='#' data-toggle='tooltip' data-placement='top' title='Click this if you also need similar assistance!'>
<img src='images/icons/meetoo.png' alt='me too' style='width:20px;height:20px;'>
</a>
<a href='#' data-toggle='tooltip' data-placement='top' title='Click this if you also need similar assistance!'>Me too</a>
       
<a href='#' data-toggle='tooltip' data-placement='top' title='Click this to direct a friend!'>
<img src='images/icons/advise.png' alt='advise' style='width:20px;height:20px;'>
</a>
<a href='#' data-toggle='tooltip' data-placement='top' title='Click this to direct a friend!'>Advise</a>
       
<a href=\"user.php?id=$id\" data-toggle='tooltip' data-placement='top' title='Click this if you will sort out this issue 100%!'>
<img src='images/icons/assist.png' alt='me too' style='width:15px;height:15px;'>
</a>
<a href=\"user.php?id=$id\" data-toggle='tooltip' data-placement='top' title='Click this if you will sort out this issue 100%!'>Assist</a>           </span> </br> </br>"; // added after the comment
if ($comment !== 'NULL')
{
echo "<div style='margin-left:35%; font-size:80%'> <center><u style='font-size:75%;'>
<strong> Advises </strong> </u></center></br>
<a href=\"user.php?id=$id2\">".
'<img src="'.htmlentities($row["commenter_photo"], ENT_QUOTES, 'UTF-8').'" alt="Avatar" style="max-width:50px;max-height:50px;" />'." ".$row["commenter_fname"]. " ".$row["commenter_sname"]." </a> said:
<span style='color:blue;'>".$row["comment"]." </span>
<span style='margin-left:8%;'> on <span style='color:green;'>".$row["comment_date"]." </span></span> </br>";
}else {
echo 'Nothing to show';
}
?>
</div>
</div>
<?php } // issue was it was taken as html as php tags were not included
?>
if(!empty($interest)){
foreach ($interest as $key => $value) {
echo "<div style='float:left; height:130px; width:100px; margin-left:10px; border:solid #f8f8f8; background-color: #f8f8f8;'>";
echo "<a class='avatar' href='#'><img width='90' height='40' src=".$value['item_image']."></a>";
echo "<div><i>".$value['item_name']."</i></div>";
echo "<a href='#' style='text-decoration: none; outline: none;'><span class='label label-success' value=".$value['item_id']." id=".$value['item_id']." onClick='reply_click1(this.id)'>Added</span></a>";
echo " </div>";
}
}
this is my code I'm printing images horizontally here but i need to print two images per line !
this is my output .
I need two items per row
i tried to put <hr> and <br> it did not help me ! is there any way to do this?
$counter = 0;
foreach ($interest as $key => $value) {
$counter++;
if($counter%2==0){
echo '<div style="clear:both;"></div>';
}
echo "<div style='float:left; height:130px; width:100px; margin-left:10px; border:solid #f8f8f8; background-color: #f8f8f8;'>";
echo "<a class='avatar' href='#'><img width='90' height='40' src=".$value['item_image']."></a>";
echo "<div><i>".$value['item_name']."</i></div>";
echo "<a href='#' style='text-decoration: none; outline: none;'><span class='label label-success' value=".$value['item_id']." id=".$value['item_id']." onClick='reply_click1(this.id)'>Added</span></a>";
echo " </div>";
}
}
Because you have float:left css property, you must write a <br style="clear:both" />
easy way to define your div width:50% in style or use clear:both in br