I have one query. Through while loop I am displaying three random songs from database and displaying them but I don't want to display all three.
When users click on the first song play icon it starts playing and after it finishes first song it automatically goes to second song and after second song completes it goes to third song.
But I want to display only one block which is playing for example first block will be displayed and when users click on first it will start playing but when first completes it should scroll up and second song which is playing should be visible to visitor.
Here is my php code:
$res6411 = sql_query("SELECT * from `".tb()."stories` where app='music' order by rand() desc limit 3");
while($row6411 = sql_fetch_array($res6411)) {
$outputmusic .= ' <div id="playlist"> <div href="'.$row6411['var1'].'" style="width: 520px;" class="item">
<div>
<div class="fr duration"></div>
<div class="btn play"></div>
<div class="title">'.$row6411['title'].'</div>
</div>
<div class="player inactive"></div>
</div> </div>
here is css
b{color:#555;font-weight:bold}.duration{font-size:10px;color:#777}.btn.play{width:16px;height:17px;background-image:url(i/play.gif);display:inline-block}.btn.pause{width:16px;height:17px;background-image:url(i/pause.gif?2)}.btn.paused{width:16px;height:17px;background-image:url(i/play.gif?3);display:inline-block}div.player{width:520px;height:14px;margin-top:5px;padding-left:20px}div.player.inactive{margin-top:0px;margin-bottom:0;border-top:dashed 0px #555}.item .title{-vertical-align:middle}.item .btn{display:inline;float:left;margin-right:5px;cursor:pointer}
Here is output from firebug.
It displays three blocks. I want to display only playing song and when first song finishes playing it automatically goes to second that time first should scroll up and second song should display
<div id="playlist" class="playlist1"> <div class="item" style="width: 520px;" href="uploads/userfiles/201206/1110_27_aslha.[Songs.PK]Blue-05-BlueTheme.mp3">
<div>
<div class="fr duration"></div>
<div class="btn play"></div>
<div class="title">Blue Theme</div>
</div>
<div class="player inactive"></div>
</div><div class="item current" style="width: 520px;" href="uploads/userfiles/201206/110_48_7jngc.ChaleChalo.mp3">
<div>
<div class="fr duration"></div>
<div class="btn pause"></div>
<div class="title">Chale Chalo</div>
</div>
<div class="player"><embed width="380" height="5" flashvars="url=uploads/userfiles/201206/110_48_7jngc.ChaleChalo.mp3&id=playlist1&backgroundColor=16777215&volumeBarWidth=40&progressBarWidth=320&barSpace=20&volumeBarColor=5592405&volumeBarHeight=1&volumeSliderWidth=10&volumeSliderHeight=5&volumeSliderColor=5592405&progressBarHeight=1&progressSliderWidth=10&progressSliderHeight=5&progressSliderColor=5592405&progressBarColor=10066329&bufferColor=5592405" allowscriptaccess="sameDomain" swliveconnect="true" quality="high" name="playerplaylist1" id="playerplaylist1" style="undefined" src="swf/drplayer.swf" type="application/x-shockwave-flash" wmode="transparent"></div>
</div><div class="item" style="width: 520px;" href="uploads/userfiles/201206/117_49_6l7ag.01KahonaKaho-AmirJama.mp3">
<div>
<div class="fr duration"></div>
<div class="btn play"></div>
<div class="title">Kaho na Kaho - murder</div>
</div>
<div class="player inactive"></div>
</div></div>
It seems you're already setting a "current" css class on the currently playing item. You can leverage this by just animating the divs based on this class. If you want all inactive items to be invisible, do something like this.
In your CSS:
.item{display:none;}
In your jquery:
//When doc is ready
$(function(){
$('.item').slideUp();
$('.item.current').slideDown();
});
//You can set a speed/duration for this animation. See more info here: http://api.jquery.com/slideDown/
Make sure you reference jquery in your head as well. You can link to this from Google: https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
Related
I am creating a project on PHP. But I have a problem. I want to pass some values from a section to another section. For example: In first section I am showing all products, and second section I am showing product details. When I click a product on first section, products values should pass second section. I am sharing my codes. Thanks
First Section
<section class="section pb-60 sm-pt-90">
<!-- Portfolio Items -->
<div id="portfolio-gallery" class="portfolio-container isotope-container portfolio-gallery row animated mfp-gallery" data-animation="fadeInUp" data-animation-delay="1200">
<article class="portfolio-item isotope-item col-md-4 col-sm-6 tasarim">
<div class="project-container">
<a href="http://blogaktuel.com//upload/Ekran Alıntısı.PNG" data-size="1080x1440" class="portfolio-gallery__img--main">
<img src="http://blogaktuel.com//upload/Ekran Alıntısı.PNG" alt="" style="width:360px; height:256px;">
<div class="overlay">
<div class="overlay-wrapper">
<div class="overlay-inner background-dark-5 opacity-70"></div>
</div>
</div>
</a>
<div class="project-details">
<h4 class="project-title heading-uppercase">Yeni Proje Mesela</h4>
</div>
</div>
</article>
Second Section
<div id="detay" class="ed-slide">
<div class="slide-container">
<div class="slide-content">
<section class="section sm-pt-0">
<div class="container">
<h2 class="text-white text-center animated" data-animation="fadeInDown"><!-- Project Title --></h2>
<div class="divider divider-alt divider-center divider-light animated" data-animation="fadeInDown" data-animation-delay="300"><span></span></div>
<p class="lead text-white mb-50 text-center animated" data-animation="fadeInDown" data-animation-delay="600"><!-- Project Info --></p>
<!-- Project Images etc. -->
</div>
</section>
</div>
</div>
</div>
You can make that using 2 ways:
-First way: when clicking on a product, you reload the page, and you pass the id in the url, and you display the data in the other section.
-Second way(Best way): via jquery for example, when clicking on a product, you load the data for this product and you display it in the other section.
I solved my problem with jQuery. I am sharing jQuery codes.
$(".details").click(function(){
var proje_baslik = $("input[name=proje_baslik]").val();
var proje_aciklama = $("input[name=proje_aciklama]").val();
var proje_url = $("input[name=proje_url]").val();
var proje_fiyat = $("input[name=proje_fiyat]").val();
var proje_resim = $("input[name=proje_resim]").val();
$("#detay .proje_baslik").html(proje_baslik);
$("#detay .proje_aciklama").html(proje_aciklama);
window.location.href = "http://localhost:81/Projeler/kodaktuelOnePage/#detay";});
Thanks for all comments
I have the following code:
<div class="container-fluid>
{files}
<div class="media">
<div class="media-left">
<img src="<?php echo base_url('files/{filename}'); ?>" alt="afbeelding" class="media-object" style="width:200px">
</div>
<div class="media-body">
<h4 class="media-heading">{title}</h4>
<p>{text}</p>
</div>
</div>
<br>
{/files}
</div>
The current result is just the title and text being shown, without the image. When I remove the whole div with class "media-body", the image shows. I think my code is structured right, I followed the w3-schools example. How can I get both the image and text to show up in the bootstrap media format?
Missing "
Change from
<div class="container-fluid>
to
<div class="container-fluid">
I'm trying to make a page that gets entries from a database and displays them in a <div> called "gallery-item". However the lightbox works, it only shows the first entry of the database. I hope someone can make sense of this code and may be able to help me with my problem.
My html/php/sql
<?php if (isset($_POST["Website"])) {
$query=$db->prepare("SELECT * FROM `portfoliodb`.`website`");
$query->execute();
while ( $row = $query->fetch()){
$website_id = $row['website_id'];
$website_name = $row ['website_name'];
$website_desc_en = $row ['website_desc_en'];
$website_tags = $row ['website_tags'];
$website_image = $row ['website_image'];
$website_type = $row['website_type'];
echo'
<div class="background hidden" id="background"></div>
<a>
<div class="lightbox hidden" id="lightbox">
<div class="box-title hidden" id="box-title">
<h4 class="hidden" id="box-title-h">' . htmlspecialchars($website_name) . '</h4>
<h4 class="close hidden" id="close">X</h4>
</div>
<div class="box-img hidden" id="box-img">
</div>
<div class="box-foot hidden" id="box-foot">
<div class="box-space hidden" id="box-space"></div>
<div class="box-desc hidden" id="box-desc">
<p class="desc-text hidden" id="box-text">'. htmlspecialchars($website_desc_en) .' </p>
</div>
<div class="tag-space-box hidden" id="box-tags-space"></div>
<div class="tag-box hidden" id="box-tags">
<small id="box-small" class="hidden">'. htmlspecialchars($website_tags) .'</small>
</div>
</div>
</div>
</a>
<a>
<div class="gallery-item-web button" id="button">
<p class="gallary-item-text">';
echo htmlspecialchars($website_name);
echo'</p>';
echo '<i class="fa fa-desktop fa-3x position-icon"></i>
</div></a>
';
}}
The gallery shows all entries in the database so that works fine, the only problem is that the lightbox shows the first entry, so if I were to have a database with the entries "Apples, Pears, Oranges", the gallery would display "Apples, Pears, Oranges". But the lightbox would display "Apples" on every single entry.
My Jquery
$(document).ready(function(){
$(".button").click(function(){
$("#background").toggleClass("hidden");
$("#lightbox").toggleClass("hidden");
$("#box-title").toggleClass("hidden");
$("#box-title-h").toggleClass("hidden");
$(".close").toggleClass("hidden");
$("#box-img").toggleClass("hidden");
$("#box-foot").toggleClass("hidden");
$("#box-space").toggleClass("hidden");
$("#box-desc").toggleClass("hidden");
$("#box-text").toggleClass("hidden");
$("#box-tags-space").toggleClass("hidden");
$("#box-tags").toggleClass("hidden");
$("#box-small").toggleClass("hidden");
});
$(".close").click(function(){
$("#background").toggleClass("hidden");
$("#lightbox").toggleClass("hidden");
$("#box-title").toggleClass("hidden");
$("#box-title-h").toggleClass("hidden");
$(".close").toggleClass("hidden");
$("#box-img").toggleClass("hidden");
$("#box-foot").toggleClass("hidden");
$("#box-space").toggleClass("hidden");
$("#box-desc").toggleClass("hidden");
$("#box-text").toggleClass("hidden");
$("#box-tags-space").toggleClass("hidden");
$("#box-tags").toggleClass("hidden");
$("#box-small").toggleClass("hidden");
});
$(".background").click(function(){
$("#background").toggleClass("hidden");
$("#lightbox").toggleClass("hidden");
$("#box-title").toggleClass("hidden");
$("#box-title-h").toggleClass("hidden");
$(".close").toggleClass("hidden");
$("#box-img").toggleClass("hidden");
$("#box-foot").toggleClass("hidden");
$("#box-space").toggleClass("hidden");
$("#box-desc").toggleClass("hidden");
$("#box-text").toggleClass("hidden");
$("#box-tags-space").toggleClass("hidden");
$("#box-tags").toggleClass("hidden");
$("#box-small").toggleClass("hidden");
});
});
(It's pretty bad I know, this is my first time using Jquery)
This is the Jquery for the lightbox, it toggles the class on every item of the lightbox to "hidden". Whih basically makes every item with that class invisible, great for a lightbox.
First off, you don't need to add class of "hidden" to every element. You can just add it to the container element and then all tags inside would also be hidden.
Your main mistake was to have the same ids and classes for all images, you will need to ensure that each image has an unique identifier.
Try my solution: https://jsfiddle.net/3vhv90ce/2/
HTML:
<div class="container1">
<div class="background" id="background"></div>
<a>
<div class="lightbox" id="lightbox">
<div class="box-title" id="box-title">
<h4 class="" id="box-title-h">name</h4>
<h4 class="close" id="close">X</h4>
</div>
<div class="box-img" id="box-img">
</div>
<div class="box-foot" id="box-foot">
<div class="box-space" id="box-space"></div>
<div class="box-desc" id="box-desc">
<p class="desc-text" id="box-text">description</p>
</div>
<div class="tag-space-box" id="box-tags-space"></div>
<div class="tag-box" id="box-tags">
<small id="box-small" class="">tags</small>
</div>
</div>
</div>
</a>
</div>
</div>
<div class="gallery-item-web button" data-id="1">
<p class="gallary-item-text">Click me</p>
<i class="fa fa-desktop fa-3x position-icon"></i>
</div>
<div class="container2">
<div class="background" id="background"></div>
<a>
<div class="lightbox" id="lightbox">
<div class="box-title" id="box-title">
<h4 class="" id="box-title-h">name</h4>
<h4 class="close" id="close">X</h4>
</div>
<div class="box-img" id="box-img">
</div>
<div class="box-foot" id="box-foot">
<div class="box-space" id="box-space"></div>
<div class="box-desc" id="box-desc">
<p class="desc-text" id="box-text">description</p>
</div>
<div class="tag-space-box" id="box-tags-space"></div>
<div class="tag-box" id="box-tags">
<small id="box-small" class="">tags</small>
</div>
</div>
</div>
</a>
</div>
</div>
<div class="gallery-item-web button" data-id="2">
<p class="gallary-item-text">Click me</p>
<i class="fa fa-desktop fa-3x position-icon"></i>
</div>
JS:
$(document).ready(function(){
$(".button").click(function(){
$('.container'+$(this).data('id')).toggleClass("hidden");
});
});
CSS:
.hidden {
display: none;
}
.gallery-item-web {
cursor: pointer;
}
I suppose your problem came from those lines:
<div class="background hidden" id="background"></div>
<div class="gallery-item-web button" id="button">
you have many controls with the same id, And this is ambiguous for jQuery.
I have a piece of jquery code which load a file as
$(".data_container").load(base_path+"sign_up/signup.php?trigger_id=random");
Signup.php contains
<?php include_once("../libs/php_header/php_header.php"); ?>
<div class="ui modal s_umodal">
<i class="close icon"></i>
<div class="header">
Modal Title
</div>
<div class="image content">
<div class="image">
An image can appear on left or an icon
</div>
<div class="description">
A description can appear on the right
</div>
</div>
<div class="actions">
<div class="ui button">Cancel</div>
<div class="ui button">OK</div>
</div>
</div>
<script>
$('.s_umodal')
.modal('show');
</script>
The problem is, I can call the modal box and it shows up. but next time I click on the trigger button (button to show modal) it display another one even though I have closed the previous one. so now I am left with two modal boxes. and if I click multiple times i will be left with multiple modal boxes. I am using Semantic-UI.
The problem with your implementation is that every time you call $('.data_container').load(base_path+"sign_up/signup.php?trigger_id=random"); you are creating a new dom element with the div you are fetching from that ajax call. $('.s_umodal').modal('show'); is then showing all of the modal boxes returned from the server.
Without restructuring your code significantly, One approach is to not keep fetching the content of the div over and over again. The <div> will be a part of the main html that contains data_container. Your Ajax call can return the script that shows the dialog box.
HTML:
<div class="data_container"></div>
<div class="ui modal s_umodal">
<i class="close icon"></i>
<div class="header">
Modal Title
</div>
<div class="image content">
<div class="image">
An image can appear on left or an icon
</div>
<div class="description">
A description can appear on the right
</div>
</div>
<div class="actions">
<div class="ui button">Cancel</div>
<div class="ui button">OK</div>
</div>
</div>
Your Ajax call could be returning:
<script>
$('.s_umodal').modal('show');
</script>
Your call to load the content could remain the same.
$(".data_container").load(base_path+"sign_up/signup.php?trigger_id=random");
If you are up for a significant change however, You can try to use JSON web services instead of returning <script>.
Well, as the title says, I am not able to display the content in the tabs.
What I am doing is I am fetching the data from MySQL table and displaying it in tabs (successfully fetched).
What I am facing the problem is when the page is done with loading, I have to click one of the tabs in order to display all the contents of the tabs.
Here's the code for the tabs:
<div class="tabbable">
<ul class="nav nav-tabs">
<li class="active">
Description
</li>
<li>
Terms and Conditions
</li>
<li>
Returns and Cancellation
</li>
</ul>
<div class="tab-content">
<div class="tab-pane" id="description">
<p class="lead text-justify" style="margin: 10px 5px;">
<?php echo $descrip; ?>
</p>
</div>
<div class="tab-pane" id="terms">
<p class="lead text-justify" style="margin: 10px 5px;">
<?php echo $termsAndCond; ?>
</p>
</div>
<div class="tab-pane" id="returns">
<p class="lead text-justify" style="margin: 10px 5px;">
<?php echo $returnsAndCan; ?>
</p>
</div>
</div>
</div>
The data is displayed once clicked on either of the tabs from the code above. I don't know where I have made the mistake. Kindly help me out in rectifying it.
Thank You in advance.
Next to setting the Description tab active which you did by setting <li class="active"> you also have to set the Description tabs content active. I think you forgot to do this.
Add the class active to the first tab-pane, so change it from <div class="tab-pane" id="description"> into <div class="tab-pane active" id="description">.
See http://getbootstrap.com/javascript/#tabs for more documentation about Bootstraps tab component.