How can i clone the below HTML5 wrap. The code contains also some php serialized that must be in order , example Article one has <?php echo $price[n];?> where n must be a number from 0-15.
<!-- ARTICLE START -->
<div class="col-sm-6 col-md-4">
<article class="box has-discount">
<figure>
<a class="hover-effect popup-gallery" href=
"ajax/slideshow-popup.html"><img alt="" height="161" src=
"<php echo $img[0];?>" width="270"></a> <span class=
"discount"><span class="discount-text">VIP
DISCOUNT</span></span>
</figure>
<div class="details">
<span class="price"><small>avg/night</small> $<php echo $price[0];?></span>
<h4 class="box-title"><php echo $name[0];?>small><php echo $city[0];?></small></h4>
<div class="feedback">
<div class="five-stars-container" data-original-title=
"4 stars" data-placement="bottom" data-toggle="tooltip"
title="">
<span class="five-stars" style="width: 80%;"></span>
</div><span class="review">270 reviews</span>
</div>
<p class="description">Nunc cursus libero purus ac congue arcu
cursus ut sed vitae pulvinar massa idporta nequetiam.</p>
<div class="action">
<a class="button btn-small" href=
"hotel-detailed.html">SELECT</a> <a class=
"button btn-small yellow popup-map" data-box=
"48.856614, 2.352222" href="#">VIEW ON MAP</a>
</div>
</div>
</article>
</div>
<!-- ARTICLE END -->
I have a code that generates arround 20-30 hotels,
Each hotel has his own article and his own variable as $price[], $name[], etc were the [n] value in a number in ascending order starting from 0.
How can i generate the above div x how many hotels availeble and to insert the variable value automatic ?.
something like this? http://jsfiddle.net/swm53ran/173/
i simplified the code a bit and did everything in jquery, but i put notes on how to do it with php (i dont have readily available access to php editor) but the concept is the same.
<div class="hotel" id="template" style="display:none;">
<div class="name"></div>
<div class="price"></div>
</div>
$(document).ready(function() {
var hotels = [
{'name': 'hotel1', 'price':'$200'},
{'name': 'hotel2', 'price':'$300'},
{'name': 'hotel3', 'price':'$700'},
{'name': 'hotel4', 'price':'$100'}
];
for(var i = 0; i < hotels.length; i++) {
var clone = $('#template').clone(true).attr('id', '');
clone.css('display', '');
clone.find('.name').html('Name: ' + hotels[i]['name'] + '. With php should be something like < ? php echo $name[i]; ? >');
clone.find('.price').html('Price: ' + hotels[i]['price'] + '. With php should be something like < ? php echo $price[i]; ? >');
clone.appendTo('body');
}
});
you'd get the hotels array from php (im assuming) and then you can put php right into the html of the clone if you take out the spaces, then use i as the incrementor from the for loop. hope this helps
Related
$divs = $xpathsuj->query("//div[#class='txt-msg text-enrichi-forum ']");
$div = $divs[$i];
With this XPath command I'm able to select the div with the class "txt-msg text-enrichi-forum " :
<div class="bloc-contenu">
<div class="txt-msg text-enrichi-forum ">
<p>Tu pourrais écrire en FRANCAIS si ce n'est pas trop demandé?
<img src="http://image.jeuxvideo.com/smileys_img/54.gif" alt=":coeur:" data-code=":coeur:" title=":coeur:" width="21" height="20" />
</p>
</div>
</div>
But not this one :
<div class="bloc-contenu">
<div class="txt-msg text-enrichi-forum ">
<p>
<img src="http://image.jeuxvideo.com/smileys_img/42.gif" alt=":salut:" data-code=":salut:" title=":salut:" width="46" height="41" />
</p>
</div>
<div class="signature-msg text-enrichi-forum ">
<p>break;</p>
</div>
</div>
What am I doing wrong?
I've tried it with both segments of XML and it seems to work with both, but there is a possibility that there is some issue with spacing.
In your XPath query, your looking for an exact match of 'txt-msg text-enrichi-forum ' which has two spaces after txt-msg and one after the last part. If any spaces are missing, then this will not find the element.
If you change it to...
$divs = $xpathsuj->query("//div[contains(#class,'txt-msg') and contains(#class,'text-enrichi-forum')]");
foreach ( $divs as $div ) {
echo $doc->saveXML($div).PHP_EOL;
}
It should be a bit more tolerant.
I've got a webpage that is outputted through CKEditor. I need it to display the image without the <p></p> tags but I need it to leave the actual text within the paragraph tags so I can target it for styling.
I've tried to achieve this through the jQuery below that I found on another post here but it isn't working for me..
I have tried:
$('img').unwrap();
and I've tried:
$('p > *').unwrap();
Both of these don't work. I can disable the tags altogether from my editors config, but I wont be able to target the text on it's own if it's not wrapped in a tag.
The outputted HTML is:
<body>
<div id="container" class="container">
<p><img alt="" src="http://localhost/integrated/uploads/images/roast-dinner-main-xlarge%281%29.jpg" style="height:300px; width:400px" /></p><p>Our roast dinners are buy one get one free!</p>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('p > *').unwrap();
});
</script>
</body>
All help is appreciated!
Usually done using
$('img').unwrap("p");
but this will also orphan any other content (like text) from it's <p> parent (that contained the image).
So basically you want to move the image out of the <p> tags.
There's two places you can move your image: before or after the p tag:
$("p:has(img)").before(function() { // or use .after()
return $(this).find("img");
});
p {
background: red;
padding: 10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="container" class="container">
<p>
<img alt="" src="http://placehold.it/50x50/f0b" />
</p>
<p>
Our roast dinners are buy one get one free!
</p>
</div>
<p>
<img src="http://placehold.it/50x50/f0b" alt="">
Lorem ipsum dolor ay ay
<img src="http://placehold.it/50x50/0bf" alt="">
</p>
<p>
<img src="http://placehold.it/50x50/0bf" alt="">
</p>
although notice that the above will not remove the empty <p> tags we left behind. See here how to remove empty p tags
Remedy
If you want to remove the empty paragraphs - if the image was the only child -
and keep paragraphs that had both image and other content:
$("p:has(img)").each(function() {
$(this).before( $(this).find("img") );
if(!$.trim(this.innerHTML).length) $(this).remove();
});
p{
background:red;
padding: 10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="container" class="container">
<p>
<img alt="" src="http://placehold.it/50x50/f0b" />
</p>
<p>
Our roast dinners are buy one get one free!
</p>
</div>
<p>
<img src="http://placehold.it/50x50/f0b" alt="">
Lorem ipsum dolor ay ay
<img src="http://placehold.it/50x50/0bf" alt="">
</p>
<p>
<img src="http://placehold.it/50x50/0bf" alt="">
</p>
This will work for sure
var par = $(".par");
var tmp = par.find('.img').clone();
var parent = par.parent();
par.remove();
tmp.appendTo(parent);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="parent">
<p class="par">
<img src="https://webkit.org/demos/srcset/image-src.png" class="img" alt="">
</p>
</div>
Here is my CODE. I'm using php 5.4 and the PDO connection!
I included my database connection and some other files i need. And now I have a registration form wich i add some values from filling them. The ridirection is made and not a problem is shown. But when I check the DB is not added. Where I'm going wrong?
Code
<?php
include'db.php';
include'header.php';
require 'vendndodhje.php';
$VendndodhjeInput = new Vendndodhje();
if ( !empty($_POST)) {
// keep track validation errors
$emerError = null;
$mbiemerlError = null;
$dtlError = null;
$telError = null;
$emailError = null;
$vendndodhjeError=null;
// keep track post values
$emer = $_POST['emer'];
$mbiemer = $_POST['mbiemer'];
$datelindje = $_POST['datelindje'];
$tel = $_POST['tel'];
$email = $_POST['email'];
$Vendndodhje=$_POST['Vendndodhje'];
//insert values
if ($valid) {
$pdo = Database::connect();
$sql = "INSERT INTO klienti(emer,mbiemer,datelindje,tel,email,Vendndodhje,date_aplikimi) VALUES(?, ?, ?, ?, ?, ?, NOW())";
$q = $pdo->prepare($sql);
$q->execute(array($emer, $mbiemer, $datelindje, $tel,$email, $Vendndodhje));
}
header("Location: form'.php");
}
?>
You can try something like this:
$(document).ready(function($) {
$('#accordion').find('.accordion-toggle').click(function() {
//Expand or collapse this panel
$(this).next().slideToggle(500);
//Hide the other panels
$(".accordion-content").not($(this).next()).slideUp(1000);
$(".active").removeClass("active");
$("#accordion")
.find(".glyphicon")
.removeClass("glyphicon-remove-circle")
.addClass("glyphicon-plus-sign")
$(this)
.addClass("active")
.find('.glyphicon')
.removeClass("glyphicon-plus-sign")
.addClass("glyphicon-remove-circle")
});
});
.active > .glyphicon{
color:orange;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/>
<div id="accordion">
<h4 class="accordion-toggle active">
<span class="glyphicon glyphicon-remove-circle"></span>
Wise busy ast both park when an ye no Nay likely her</h4>
<div class="accordion-content default">
<p>
Cras malesuada ultrices augue molestie risus.</p>
</div>
<h4 class="accordion-toggle">
<span class="glyphicon glyphicon-plus-sign"> </span>
Written enquire painful ye to offuces forming it</h4>
<div class="accordion-content">
<p>
Lorem ipsum dolor sit amet mauris eu turpis.</p>
</div>
<h4 class="accordion-toggle">
<span class="glyphicon glyphicon-plus-sign"> </span>
In finished on he speaking suitable advanced if happines</h4>
<div class="accordion-content">
<p>
Vivamus facilisisnibh scelerisque laoreet.</p>
</div>
<h4 class="accordion-toggle">
<span class="glyphicon glyphicon-plus-sign"> </span>
People as period twenty my extent as Set was better</h4>
<div class="accordion-content">
<p>
Vivamus facilisisnibh scelerisque laoreet.</p>
</div>
</div>
add class to your <span class="glyphicon glyphicon-plus-sign MyIcon"> then add css MyIcon:active{background:orange;}
Hello I'm new to php development... I want to understand how to get details from database and display on HTML CSS... I have a database i'm saving hotel data... Now I want to pull these data and display it on website.. please find below html codes design...
<div class="offset-2">
<div class="col-md-4 offset-0">
<div class="listitem2">
<img src="images/items/item7.jpg" alt=""/>
<div class="liover"></div>
<a class="fav-icon" href="#"></a>
<a class="book-icon" href="details.html"></a>
</div>
</div>
<div class="col-md-8 offset-0">
<div class="itemlabel3">
<div class="labelright">
<img src="images/filter-rating-5.png" width="60" alt=""/><br/><br/><br/>
<img src="images/user-rating-5.png" width="60" alt=""/><br/>
<span class="size11 grey">18 Reviews</span><br/><br/>
<span class="green size18"><b>$36.00</b></span><br/>
<span class="size11 grey">avg/night</span><br/><br/><br/>
<form action="http://demo.titanicthemes.com/travel/details.html">
<button class="bookbtn mt1" type="submit">Book</button>
</form>
</div>
<div class="labelleft2">
<b>Mabely Grand Hotel</b><br/><br/><br/>
<p class="grey">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum nec semper lectus. Suspendisse placerat enim mauris, eget lobortis nisi egestas et.
Donec elementum metus et mi aliquam eleifend. Suspendisse volutpat egestas rhoncus.</p><br/>
<ul class="hotelpreferences">
<li class="icohp-internet"></li>
<li class="icohp-air"></li>
<li class="icohp-pool"></li>
<li class="icohp-childcare"></li>
<li class="icohp-fitness"></li>
<li class="icohp-breakfast"></li>
<li class="icohp-parking"></li>
<li class="icohp-pets"></li>
<li class="icohp-spa"></li>
</ul>
</div>
</div>
</div>
</div>
Please Suggest at the earliest
Example:
<?php
$database_data = array(
array(
'name' => 'A', 'age' => 28, 'email' => 'a#abc.com'
),
array(
'name' => 'B', 'age' => 27, 'email' => 'b#abc.com'
),
array(
'name' => 'C', 'age' => 26, 'email' => 'c#abc.com'
),
);
?>
Now loop through data and echo your value
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<?php foreach($database_data as $data): ?>
<tr>
<td><?php echo $data['name']; ?></td>
<td><?php echo $data['age']; ?></td>
<td><?php echo $data['email']; ?></td>
</tr>
<?php endforeach ; ?>
</tbody>
</table>
There are so many tutorials available online around pagination with PHP and database (for example MySQL). Follow some of the below and you will understand the concept and be able to apply to your page easily.
http://www.tutorialspoint.com/php/mysql_paging_php.htm
http://php.about.com/od/phpwithmysql/ss/php_pagination.htm
http://www.developphp.com/view_lesson.php?v=289
plz use limit tag of mysql to display the as your required data ..
I want ot provide some link
1). if i use LIMIT on a mysql query, should the result set be equal to the limit?
2). Limit
and then you should set the next button which tag a parameter as Start like index.php?start=20&limit=20 and then get on your query page like
$start=isset($_GET['start'])?$_GET['start']:0;
$limit=isset($_GET['limit'])?$_GET['limit']:20;
$query = mysql_query("select * from table limit $start,$limit ");
i Hope this help ful and if you want to set the pagination in your page then follow follow links
1). Pagination of MySQL Query Results
2). Simple Pagination With PHP & MYSQL
3). PHP Pagination
hope you get solution ...
I have 3 web pages with the same code within a website. I am having success with 2 of my 3 pages. The ckeditor instances update as expected.
I have finally figured out "what the issue is", BUT still don't know how to fix it. It seems that if I type only one line of code and click out of the div (ie. blur event happens) it saves as is expected. If I hit a hard return and type other text the blur event won't save ANYTHING after the hard return. Seems to be a bug in this version of CKEDITOR. As I mentioned, I have 2 other pages with exactly the same code and everything works just fine.
<?php
session_start();
$thisPage = "services";
require('functions.php');
include('header.htm');
?>
<title>Services | Dr. Your Name</title>
<style type="text/javascript">
#cke_body {margin-left:120px;margin-top:30px;width:520px;background-color:gray;}
</style>
<script type="text/javascript">
CKEDITOR.config.filebrowserBrowseUrl= 'browser/browseAdminUploads.php';
CKEDITOR.config.extraPlugins = 'justify';
</script>
</head>
<body>
<div id="header" class="clear">
<div id="headerContent">
<?php include ("bannerIcons.php"); ?>
<div id="logo">
<img src="images/logo.png" title="home" alt=""/>
</div> <!--end logo-->
<?php include('mainMenu.php');?>
</div>
</div> <!--end header-->
<div id="container">
<div id="content" class="shadow"><div class="content">
<div id="colLt"><div class="content">
<?php
connect();
$sql = mysql_query("SELECT services FROM contentAreas") or die("nothing found");
$row = mysql_fetch_assoc($sql);
if ($_SESSION['username']=='admin'){
echo "<div id='services' contenteditable='true' onblur='saveServices()'>";
} else {
echo "<div id='services'>";
}
echo $row['services'];
echo "</div>";?>
<script type="text/javascript">
function saveServices() {
var data = CKEDITOR.instances.services.getData();
$.post('saveServices.php', {services:data})
}
</script>
</div></div>
<?php include('saveServices.php');?>
<div id="colRt"><div class="content">
<div id="serviceBox" class="shadow"><div class="content">
<p class="big italTxt">one or more testimonials could go here. Lorem ipsum dolor sit amet, mel cu atqui perfecto, nec te vero fugit denique, an vel mundi tritani concludaturque.<br><br>Laoreet erroribus eos no. Eu nec maluisset repudiandae. Possit lucilius constituam his cu, quas liber sea an, eum purto errem audire eu. In viris assentior vis, pri iudico dolorem electram ne, ea ius scripta virtute.</p>
</div></div>
</div></div><!--end colRt-->
</div></div><!--end content-->
<div id="footer">
<?php include("footer.htm") ?>
</div><!--end footer-->
<div class="clear"></div>
</div><!--end container-->
<div class="clear"></div>
</body>
</html>
My file saveServices.php is as follows:
<?php
$services=$_POST['services'];
echo "hello<br>";
echo "services: ".$services;
include('functions.php');
connect();
$sql1 = mysql_query("UPDATE contentAreas SET services = '$services'") or die ("Your information has not been posted");
?>
Thanks again for your help!
I can't believe this nor do I understand it, but when I changed my div name from "services" to "offers", it worked. Is services a reserve word? Could my function name saveServices() be too long? I would love to hear a concrete explanation about why this has happened.
Also, I upgraded from 4.0.2 standard to 4.2.2 standard.