PHP SQL - appearing outside div tag - php

I've spent all afternoon trying to figure this out with no success, I wondered if anyone could help?
I have a dropdown menu on my site which is working perfectly. I've duplicated one of the menu options and after I did this it still worked fine, it had a php / SQL query inside but once duplicate it still did what it should.
What I did then was change the SQL and although the query is correct (checked in myphpadmin) all of my results appear out side of the div tag for some reason, its as if the div tag is closing itself.
Here's my code:
'
<li>Brand<!-- Begin 4 columns Item -->
<div class="dropdown_5columns"> <!-- Begin 4 columns container -->
<div id="top"></div>
<div class="col_4">
<h2 style="width:98%;">Choose from the following Brands:</h2>
</div>
<div class="col_1" style="width:190px;">
<?php
$databrand = mysql_query("SELECT DISTINCT(brand), COUNT(*) as Total from `pt_products` where `brand` <>'' group by `brand` limit 5")
or die(mysql_error());
while($infobrand = mysqlfetch_array( $databrand ))
{
print "<li style='width:190px;'>";
print "<a href='/brand'>".$infobrand['brand']." (".$infobrand['Total'].")</a></li>";
}
print "</div>";
?>
<div id="bottom"></div>
</div><!-- End 4 columns container -->
</li>`
I can't seem to figure this one out. All I did was change the SQL Query.
I've tried deleting the duplicate content and starting again, but get the same outcome.
Any help would really be appreciated.
here's the view source data on of my site:
<li>Brand<!-- Begin 4 columns Item -->
<div class="dropdown_5columns" style="position:absolute;"> <!-- Begin 4 columns container -->
<div id="top"></div>
<div class="col_4">
<h2 style="width:98%;">Choose from the following Brands:</h2>
</div>
<div class="col_1" style="width:190px;">
<li style='width:190px;'><a href='/brand'>Balterio (50)</a></li>
<li style='width:190px;'><a href='/brand'>Dale Hardware (24)</a></li>
<li style='width:190px;'><a href='/brand'>EuroSpec Hardware (2)</a></li>
<li style='width:190px;'><a href='/brand'>Everbuild (35)</a></li>
<li style='width:190px;'><a href='/brand'>Jeld Wen (4)</a></li>
</div>
<div id="bottom"></div>
</div><!-- End 4 columns container -->
</li>
You can't tell from below but the first <li style='width:190px;'> and the </div> after the li list are higlighted in red (error) and also the last </li>
Thanks in advance for your help.

You're using <li>, which should be inside a <ul> or <ol>, which you can then put inside a <div> if you need. Alternatively, you can change the <li> to something else, such as another <div>.
Your problem is like when you put a <p> directly inside a table without nesting in <tr><td>.

Related

Checking biggest heigh from dynamic generated divs

I have a structure of divs that are generated based on php code. Each row has 3 divs. It is generated like this:
Defining columns:
<?php
$numOfCols = 3;
$rowCount = 0;
$bootstrapColWidth = 12 / $numOfCols;
?>
First row, starting the loop and defining width:
<div class="row">
#foreach($datas as $data)
<div class="col-md-<?php echo $bootstrapColWidth; ?>">
Then there's a bunch of content.
Then, in the end, each loop adds one to rowcount, and checks if the row has ended, so we can add a new one:
<?php
$rowCount++;
if($rowCount % $numOfCols == 0) echo '</div><div class="row">';
?>
#endforeach
Now, it all works great, the problem is that as I add different amounts of content on each div, the heights become different and ends up becoming quite ugly.
What I'm trying to do: I'm trying to check in each row which div has the biggest height, so I can apply the same height to the other two.
-I've thought of adding a id to each div that increments, problem is I don't know how many divs there will be, so I can't prepare for each outcome.
-I've tried selecting each row with $('row div'), problem is then all divs will become the same size as the biggest of all. And I want to check by row.
Sorry for the long question, and thanks for any input!
Bootstrap 4 has flexbox classes that allow you to do this with just css. Take a look at this example: https://getbootstrap.com/docs/4.3/utilities/flex/#align-self
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="d-flex">
<div class="align-self-stretch mr-3" style="background-color:lightblue">Aligned flex item</div>
<div class="align-self-stretch mr-3" style="background-color:lightblue">Aligned flex item<br />With<br />More<br />Lines</div>
<div class="align-self-stretch" style="background-color:lightblue">Aligned flex item</div>
</div>
I think flex-box is your solution : all into flex container will have the same height.
<div style="display:flex">
<div>
... some content
</div>
<div>
... some content
</div>
</div>
You can use .row-eq-height in Bootstrap 4

add images to slider in php. My code just adds one image

my code only shows one image from the database. I dont know whats the problem. I tried looping it with allthe divs and ul but nothing it only shows one image. my code is
<div class="fullwidthbanner-container">
<div class="fullwidthbanner">
<?php
$about = slider();
while($about_fetch=mysql_fetch_array($about)){
?>
<ul>
<li data-transition="fade" data-slotamount="7">
<img src="images/<?php echo $about_fetch["slide"];?>" alt="">
<?php
}?>
</li>
</ul>
<!--<div class="tp-bannertimer"></div>-->
</div><!-- end .banner -->
</div><!-- end .bannercontainer -->
for the code-part, try this please:
(i assume, you dont want to have several <ul> elements and only the <li>'s)
<div class="fullwidthbanner-container">
<div class="fullwidthbanner">
<ul>
<?php
$about = slider();
while($about_fetch=mysql_fetch_array($about)){ ?>
<li data-transition="fade" data-slotamount="7">
<img src="images/<?php echo $about_fetch["slide"];?>" alt="">
</li>
<?php } ?>
</ul>
</div><!-- end .fullwidthbanner -->
</div><!-- end .fullwidthbanner-container -->
Well, your HTML isn't valid. You're looping over the start of a <ul> and <li> and not closing either until after the loop.
If that isn't the problem, then we can't help you since there is no debugging information available. Break your problem up into pieces. Is the issue server-side or client-side? Look at your output HTML to be sure. What are the return values of mysql_fetch_array() for each iteration? var_dump() is your friend.

Hide content and then display the content within a tab table

I have a site where I have an availability calendar and I need to show it within a tab table, I have it working to show on both the content and then the tab table! How can I remove it from the content but still show it within the table? I have tried hiding it within the 'Manage Display' section of the content type but it removes it from both
<ul class="nav nav-tabs">
<li class="active">Description</li>
<li>Availability</li>
<li>Pricing Information</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="home"><?php if(isset($node->field_cottage_description['und'][0]['value']))
{
print $node->field_cottage_description['und'][0]['value'];
}
?> </div>
<div class="tab-pane" id="profile">
<?php
print $content['field_availability']['#children'] ;
?></div>
<div class="tab-pane" id="messages"><?php if(isset($node->field_price_guide['und'][0]['value']))
{
print $node->field_price_guide['und'][0]['value'];
}
?></div>
</div>
I hope someone can help with my issue! If it's blatantly obvious then don't be afraid to let me know.
The only way to hide it but also keep it able to run is you just close it within the task manager...
if that dont work them you may have to turn it off and back on..
if that dont work them i think you may have to script it to be able to do what you are needing

How to place Bootstrap Carousel image captions outside the carousel div?

apologies if this has been covered anywhere here. I tried searching, but only found topics related to styling and positioning captions within the carousel code…
So, I have a layout that contains three columns:
The left column contains general information related to each page/project.
The center column contains a Bootstrap 3 carousel with images.
The right column is where I was planning on displaying all the captions related to the images in the center Carousel.
I can't quite figure out how to get the captions working in the right column. To clarify, the captions will change with each carousel slide, just as they do in the default carousel setting. I basically want to move the captions off the image, and into the right column.
I am using Kirby (www.getkirby.com) as my CMS and I am using a foreach loop to get the code for the images, etc. in the carousel. Here is my current code, including the caption section (which I am trying to move…)
<div id="center" class="col-xs-12 col-sm-6 col-md-8">
<?php $imagepage = $page->children()->first() ?>
<?php if($imagepage->hasImages()): ?>
<div id="merry-go-round" class="carousel slide">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<?php $n=0; foreach($imagepage->images() as $image): $n++; ?>
<div class="item<?php if($n==1) echo ' active' ?>">
<img style="display:block; margin-left: auto; margin-right: auto;" src="<?php echo $image->url() ?>" alt="<?php echo html($image->title()) ?>" class="img-responsive">
<div class="carousel-caption"><?php echo $image->img_title() ?></div>
</div>
<?php endforeach ?>
<?php endif ?>
</div><!-- /carousel-inner -->
<!-- Controls -->
<a class="left carousel-control" href="#merry-go-round" data-slide="prev"></a>
<a class="right carousel-control" href="#merry-go-round" data-slide="next"></a>
</div><!-- /merry-go-round -->
</div><!-- /#center -->
<div id="right" class="col-xs-12 col-sm-3 col-md-2">
<p>THIS IS WHERE I AM TRYING TO PUT THE CAROUSEL CAPTIONS…</p>
</div><!-- /#right -->
I've tried by best but I am all out of ideas. I thought maybe I could do something like make the caption a variable:
<?php $test_caption = $image->img_title() ?><?php echo $test_caption ?>
but this doesn't work outside the carousel area. I'm guessing it's that it won't work outside of the foreach loop?
Anyway, if anyone has any suggestions I would really appreciate it. I'm learning PHP as I go along, but I don't know any javascript so I'm hoping there's a solution outside that. And again, I'm using Bootstrap 3.
Here is a link to a fiddle I made (without all the php stuff…):
http://jsfiddle.net/4tMfJ/2/
Based on Twitter Bootstrap Carousel - access current index
You can add the code below to your javascript (after loading jquery / bootstrap)
$(function() {
$('.carousel').carousel();
var caption = $('div.item:nth-child(1) .carousel-caption');
$('#right h1').html(caption.html());
caption.css('display','none');
$(".carousel").on('slide.bs.carousel', function(evt) {
var caption = $('div.item:nth-child(' + ($(evt.relatedTarget).index()+1) + ') .carousel-caption');
$('#right h1').html(caption.html());
caption.css('display','none');
});
});
also see: http://jsfiddle.net/4tMfJ/3/
Thanks Bass for your answer it worked for me !
But i did not want to have replicated content so i did it my way ;)
$("#slider").on('slide.bs.carousel', function(evt) {
var step = $(evt.relatedTarget).index();
$('#slider_captions .carousel-caption:not(#caption-'+step+')').fadeOut('fast', function() {
$('#caption-'+step).fadeIn();
});
});
http://jsfiddle.net/4fBVV/3/

slideToggle not working for me

Im trying to make a left side navigation that slides down with sub categories when you click on one of the links.
I've got it to work for the top link only but the others dont work.
In my header file I have some jquery script like this:
<script>
$(document).ready(function(){
$("#flip").click(function(){
$("#panel").slideToggle("slow");
});
});
</script>
in my HTML/PHP i have this code:
<div id="left-prod-nav">
<ul>
<li class="top">Product Categories</li>
<?for($i = 0; $i < $count; $i++)
{?>
<div id="flip"><li><img src="images/arrowright_off.gif" style="padding:0px; margin:0px;float:right;"><?=$result[$i]['categoryName']?></li> </div>
<div id="panel">Hello world!</div>
<?}?>
</ul>
<div class="clear"> </div>
</div>
so the navigation is there...and when I click on the top one, the others slide down so you can see the sub categories for the one I clicked.
however if I click any of the others nothing happens.
has anyone had this problem before or know how to solve it looking at my code?
Thanks
I can assume you are trying to accomplish something like this: http://jsfiddle.net/QQRy8/
$(".flip").click(function(){
$(this).next(".panel").slideToggle("slow");
});
I changed your jQuery to use classes, you should change your PHP to give each div a class name instead of an ID (ID's must be unique!)
This answer is based off this HTML:
<div class="flip">
<li>
cool
</li>
</div>
<div class="panel" style="display: none;">Hello world!</div>

Categories