I have this following snippet:
<?php
if($people->num_rows >= 1) {
while($person = $people->fetch_object()) {
echo '
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="card card-user">
<div class="content">
<div class="author">
<a href="'.$system->getDomain()?>/user/<?=$person->id.'">
<img class="avatar" src="'.$system->getProfilePicture($person).'">
<h4 class="title">'.$system->getFirstName($person->full_name).', '.$person->age.'</h4>
</a>
</div>
<p class="text-center text-muted">
';
echo $person->city.$system->ifComma($person->city); echo ' '.$person->country.'
</p>
</div>
</div>
</div>
';
}
} else {
?>
however next to the actual age (after the closing H4 tag) I'd like to add a further function which shows the current online status of the user.
The code for this would be as follows:
<?php if($system->isOnline($profile->last_active)) { echo '<i class="online-status online"></i>'; } else { echo '<i class="online-status offline"></i>'; } ?>
What is the best way to combine this snippet (online status) with the statement above?
Some expert help would be greatly appreciated
Separate your HTML and PHP code and do it like the below. Your requirement is done using a single line ternary operator.
<?php
if($people->num_rows >= 1) {
while($person = $people->fetch_object()) { ?>
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="card card-user">
<div class="content">
<div class="author">
<a href="<?php echo $system->getDomain().'/user/'.$person->id;?>">
<img class="avatar" src="<?php echo $system->getProfilePicture($person);?>">
<h4 class="title"><?php echo $system->getFirstName($person->full_name).', '.$person->age;?></h4>
<?php echo ($system->isOnline($profile->last_active)) ? '<i class="online-status online"></i>' : '<i class="online-status offline"></i>'; ?>
</a>
</div>
<p class="text-center text-muted">
<?php echo $person->city.$system->ifComma($person->city); echo ' '.$person->country;?>
</p>
</div>
</div>
</div>
<?php
}
}
?>
Related
I want to read my "pdf files" in PHPMYSQL tables. So I found the script from some forums and it's work fine in "localhost using XAMPP".
But When I deploy to website, it's not showing pdf files and all information after that line are missing.
I dont know what is the problem. Kindly someone can help me please...
<div class="page-title">
<div class="container">
<div class="row">
<div class="col-md-12">
<ol class="breadcrumb">
<li>Home</li>
<li>Journals</li>
<li><?php echo $title; ?></a></li>
</ol>
</div>
</div>
</div>
</div>
<section class="block-wrapper">
<div class="container">
<div class="row">
<div class="col-lg-8 col-md-12">
<div class="single-post">
<div class="post-title-area">
<a class="post-cat" href="<?php echo $post_cat_link; ?>"><?php echo $category; ?></a>
<h2 class="post-title">
<?php echo $title; ?>
</h2>
<div class="post-meta">
<span class="post-date"><i class="feather icon-clock"></i> <?php echo $post_date; ?></span>
<span class="post-comment"><i class="feather icon-eye"></i>
<span><?php echo $post_views; ?></span></span>
</div>
<div class="div1">
<?php echo "View PDF File for Journal Details" ?>
<?php
mysql_connect('localhost','adminjournal','adminjournalikat');
mysql_select_db('journal');
// mysql_connect('localhost','root','');
// mysql_select_db('journal');
$sql="SELECT pdf from tbl_blog_posts";
$query=mysqli_query($conn,$sql);
while ($info=mysqli_fetch_array($query)) {
?>
<embed type="application/pdf" src="pdf/<?php echo $info['pdf'] ; ?>" width="900" height="500">
<?php
}
?>
</div>
</div>
<div class="post-content-area">
<div class="entry-content">
<?php
if ($yt_vid == "") {
?>
<div class="post-media post-featured-image">
<img src="images/blog/<?php echo $media; ?>" class="img-fluid single_blog" alt="">
</div>
<?php
}else{
?>
<div class="post-media post-video">
<div class="embed-responsive">
<iframe src="https://www.youtube.com/embed/<?php echo $yt_vid; ?>"></iframe>
</div>
</div>
<?php
}
?>
<?php echo $cont?>
<br></br>
</div>
<div class="tags-area clearfix">
<div class="post-tags">
<span>Tags:</span>
<?php
$post_tags = explode(",",$tags);
foreach ($post_tags as $tag) {
if (WBCleanURL == "true") {
$st1 = preg_replace("/[^a-zA-Z]/", " ", $tag);
$st2 = preg_replace('/\s+/', ' ', $st1);
$tag_title = strtolower(str_replace(' ', '-', $st2));
$tag_link = "tags/$tag_title";
}else{
$tag_link = "pages/tags?key=$tag_title";
}
?><?php echo $tag; ?><?php
}
?>
</div>
</div>
<div class="share-items clearfix">
<ul class="post-social-icons unstyled">
<li class="facebook">
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $sharelink; ?>">
<i class="fa fa-facebook"></i> <span class="ts-social-title">Facebook</span></a>
</li>
<li class="twitter">
<a href="https://twitter.com/intent/tweet?url=<?php echo $sharelink; ?>">
<i class="fa fa-twitter"></i> <span class="ts-social-title">Twitter</span></a>
</li>
<li class="gplus">
<a href="mailto:info#example.com?&subject=&cc=&bcc=&body=<?php echo $sharelink; ?>">
<i class="fa fa-envelope"></i> <span class="ts-social-title">Email</span></a>
</li>
</ul>
</div>
</div>
</div>
thanks for your clue that this issue because of overlapping. Finally I found out the script problem... below is the right one...
Thanks a lot and Wish You All The Best
<?php echo $cont?>
<br></br>
<?php echo "PDF File Details for Journal" ?>
<br><h4><?php echo $title;?> </h4>
I have coded this image slider that moves the image and it's details using the cursor.
I want to fetch data from database and display 4 books images with their details in each row I have tried this code but all the data have displayed in one row only.
Also if this does not take much of your time I want to make only 7 rows per page (28 books) and add numbers at the bottom of the page to move to the next 7 rows.
this is my try :
<html>
<body>
<div class="popular_causes_area section_padding">
<div class="container"> <div class="row">
<div class="col-lg-12">
<div class="causes_active owl-carousel">
<?php
try{
require('connection.php');
$sql1="select * from books ";
$rs=$db->query($sql1);
$db =null;
} catch(PDOException $ex) {
die ("Error Message ".$ex->getMessage()); }
$i=0;
while ($books = $rs->fetch()){
$i++;
$bpic = $books[2];
$btitle= $books[3];
$bq= $books[4];
$bstatus = $books[5];
$bdesc = $books[6];
$bnumber = $books[7];
$bcity = $books[8];
if ($i % 3 == 1) {
echo "<li>"; ?>
<div class="single_cause">
<div class="thumb">
<?php
if ($bpic == "" ) {
echo "<img src='img/default-image.png'
height=450px'>";
} else {
echo "<img src='img/$bpic' placeholder='nooooo'
height=450px alt=''>";
}?>
</div>
<div class="causes_content">
<div class="balance d-flex justify-content-between align-items-center">
<span>Tell:<?php echo $bnumber; ?> </span>
<span><?php echo $bcity; ?> </span>
</div>
<h4><?php echo $btitle; ?> </h4>
<p><?php echo $bdesc; echo "<br>
condation:".$bstatus; ?> </p>
</div>
</div>
</li>
<?php
} ////end of first if
if ($i % 3 == 0) {
echo "<li>"; ?>
<div class="single_cause">
<div class="thumb">
<?php
if ($bpic == "" ) {
echo "<img src='img/default-image.png' height=450px'>";
} else {
echo "<img src='img/$bpic' placeholder='nooooo' height=450px alt=''>"; ?>
</div>
<div class="causes_content">
<div class="balance d-flex justify-content-between align-items-center">
<span>Tell:<?php echo $bnumber; ?> </span>
<span><?php echo $bcity; ?> </span>
</div>
<h4><?php echo $btitle; ?> </h4>
<p><?php echo $bdesc; echo "<br>
condation:".$bstatus; ?> </p>
</div>
</div>
</li>
<?php
} //end of second if
} // end of while ?>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
This image shows what I got (all the data in one row instead of 4 books per row !):
image slider code :
<div class="popular_causes_area section_padding">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="causes_active owl-carousel">
<div class="single_cause">
<div class="thumb">
<?php
if ($bpic == "" ) {
echo "<img src='img/default-image.png' height=450px'>";
} else {
echo "<img src='img/$bpic' placeholder='nooooo' height=450px alt=''>";
}
?>
</div>
<div class="causes_content">
<div class="balance d-flex justify-content-between align-items-center">
<span>Tell:<?php echo $bnumber; ?> </span>
<span><?php echo $bcity; ?> </span>
</div>
<h4><?php echo $btitle; ?> </h4>
<p><?php echo $bdesc; echo "<br> condation:".$bstatus; ?> </p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
code i have written below is working fine but at the end of the looping the div is not closed its still opening a loop
<div class="carousel-inner">
<div class="item active">
<div class="row">
<?php
$recent_projects_sql="SELECT * from recent_projects where service_type='upholstery'";
$recent_projects_conn=mysql_query($recent_projects_sql) or die(mysql_error());
$i=0; $split=0;
while($projects=mysql_fetch_array($recent_projects_conn)) {
$i++;
?>
<div class="col-sm-3">
<div class="col-item" style="">
<div class="photo-shadow"></div>
<div class="photo">
<img src="admin/assets/images/uploads/projects/<?php echo $projects['attachment1']; ?>" alt="User one">
</div>
<div class="info">
<div class="name">
<?php echo $projects['service_name']; ?>
</div>
<div class="degination">
<?php echo $projects['sub_title']; ?>
</div>
<div class="buttons">
<a class="btn btn-theme ripple-effect" href="#">View More</a>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
<?php
$split++;
if ($split % 4 == 0){
echo '</div></div><div class="item"><div class="row">';
}
}
?>
</div>
</div>
The Div has splited very well but in end of the loop div has not been closed. Thats only the problem please provide me the help to sort out the problem
When I inspect the element the last loop will show at the given result as follows:
<div class="col-sm-3">
<div class="col-item">
<div class="photo-shadow"></div>
<div class="photo">
<img src="admin/assets/images/uploads/projects/1557301934.jpg" alt="User one">
</div>
<div class="info">
<div class="name">UPHOLSTERY</div>
<div class="degination">UPHOLSTERY</div>
<div class="buttons">
<a class="btn btn-theme ripple-effect" href="#">View More</a>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
</div></div><div class="item"><div class="row">
I want to remove the two opening div's as dynamically. How can i set this to remove opened div's at then end of the looping
I just took a quick look and it looks like you are not closing the "carousel-inner" div
<div class="carousel-inner">
<div class="item active">
<div class="row">
<?php
$recent_projects_sql = "SELECT * from recent_projects where service_type='upholstery'";
$recent_projects_conn = mysql_query( $recent_projects_sql ) or die( mysql_error() );
$i = 0;
$split = 0;
while ( $projects = mysql_fetch_array( $recent_projects_conn ) ) {
$i ++;
?>
<div class="col-sm-3">
<div class="col-item" style="">
<div class="photo-shadow"></div>
<div class="photo">
<img src="admin/assets/images/uploads/projects/<?php echo $projects['attachment1']; ?>"
alt="User one">
</div>
<div class="info">
<div class="name">
<?php echo $projects['service_name']; ?>
</div>
<div class="degination">
<?php echo $projects['sub_title']; ?>
</div>
<div class="buttons">
<a class="btn btn-theme ripple-effect" href="#">View More</a>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
<?php $split ++;
if ( $split % 4 == 0 ) {
echo '</div></div><div class="item"><div class="row">';
}
}
?>
</div>
</div>
Add a Boolean check for the execution of loop, such as $check = true;, add this within the loop.
after the loop add this
if($check){
echo " </div></div>";
}
That's because at the end of iteration (in case of mod 4 and even without it), you keep 2 divs opened
echo '</div></div><div class="item"><div class="row">';
Following is my code I am displaying details as 3 columns per row using Bootstrap class row.
I tried like changing div and some condition
<div class="container">
<?php
if($lclResult->rowCount() > 0){
while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
# code...
$lclUserName = $row['us_business_name'];
$lclImage1 = $row['us_image1'];
$lclCategory = $row['us_category'];
$lclArea = $row['us_area'];
?>
<div class="row">
<div class="col-sm-4">
<div class="card">
<img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
<div class="card-body">
<h4 class="card-title"><?php echo $lclUserName?></h4>
<p class="card-text" style="font-size: 25px;"><?php echo $lclCategory?></p>
<hr>
<i class="fa fa-map-marker" style="font-size: 23px;"><span> </span><?php echo $lclArea?></i>
<!-- See Profile -->
</div>
</div>
<?php
}
?>
</div>
<?php
} else {
?>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1> NO RESULT FOUND...</h1>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
I want to display 3 columns per row to display data. If anyone knows Please guide me with the above code.
Change your code like this
<div class="container">
<div class="row">
<?php
if($lclResult->rowCount() > 0){
while($row = $lclResult->fetch(PDO::FETCH_ASSOC)) {
# code...
$lclUserName = $row['us_business_name'];
$lclImage1 = $row['us_image1'];
$lclCategory = $row['us_category'];
$lclArea = $row['us_area'];
?>
<div class="col-sm-4">
<div class="card">
<img class="card-img-top " src="<?php echo $lclImage1 ?>" alt="Card image" style="width:100%; height: 158px;">
<div class="card-body">
<h4 class="card-title">
<?php echo $lclUserName?>
</h4>
<p class="card-text" style="font-size: 25px;">
<?php echo $lclCategory?>
</p>
<hr>
<i class="fa fa-map-marker" style="font-size: 23px;">
<span>
</span>
<?php echo $lclArea?>
</i>
<!-- See Profile -->
</div>
</div>
</div>
<?php
}
?>
<?php
} else {
?>
<div class="container">
<div class="row">
<div class="col-sm-12">
<h1> NO RESULT FOUND...
</h1>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
I am working on a PHP based website which is using Twitter Bootstrap 2. I am pulling the users from MySQL database and trying to display them in multiple frames/items of carousel on a screen rather than a single item using while loop.
This is what my carousel looks like at present, as you will notice user 5 is not supposed to appear the way it is right now and is only supposed to appear when i click on arrow on right side of the carousel.
This is what my php code looks like
<div class="carousel slide" id="myCarousel">
<h4 class="carousel-title">Text title</h4>
<div class="carousel-inner">
<?php
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
?>
<div class="item active">
<div class="span3 mef-3">
<div class="about portrait">
<div class="tooltip-demo">
<a href="#" rel="tooltip" data-placement="top" data-toggle="tooltip"
data-title="">
<img class="img-circle" width="180" height="200" data-src="holder.js/360x270"
alt="270x280"
style="" src="assets/img/adviser.png"></a>
</div>
<div class="caption">
<h3 class="name" style="text-align: center"><?php echo $row['fname']." ".$row['lname'] ?></h3>
<p style="text-align: center">
Specialities</p>
</div>
<div class="mefradio">
<input type="radio" name="adviser" id="adviser" value='<?php echo $row['user_id']."|".$row['fname']." ".$row['lname'] ?>'><br>
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
<a data-slide="prev" href="#textCarousel" class="left carousel-control">‹</a>
<a data-slide="next" href="#textCarousel" class="right carousel-control">›</a>
</div>
I will really appreciate any guidance on how to get it to work
UPDATE
This is the updated code that is working, thanks to #I can Has Kittenz
<div class="carousel slide" id="myCarousel">
<h4 class="carousel-title">Text title</h4>
<div class="carousel-inner">
<?php
$i = 1;
$next_item = true;
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
if ($i == 1) {
echo '<div class="item active">';
} elseif ($next_item == true) {
echo '<div class="item">';
}
?>
<div class="span3 mef-3">
<div class="about portrait">
<div class="tooltip-demo">
<a href="#" rel="tooltip" data-placement="top" data-toggle="tooltip"
data-title="">
<img class="img-circle" width="180" height="200" data-src="holder.js/360x270"
alt="270x280"
style="" src="assets/img/adviser.png"></a>
</div>
<div class="caption">
<h3 class="name"
style="text-align: center"><?php echo $row['fname'] . " " . $row['lname'] ?></h3>
<p style="text-align: center">
Specialities</p>
</div>
<div class="mefradio">
<input type="radio" name="adviser" id="adviser"
value='<?php echo $row['user_id'] . "|" . $row['fname'] . " " . $row['lname'] ?>'><br>
</div>
</div>
</div>
<?php
$next_item = false;
if ($i % 4 == 0) {
echo '</div>';
$next_item = true;
}
$i++;
}
?>
</div>
<a data-slide="prev" href="#myCarousel" class="left carousel-control">‹</a>
<a data-slide="next" href="#myCarousel" class="right carousel-control">›</a>
</div>
The JS that needs to go with this is as following
<script>
$(document).ready(function(){
$('#myCarousel').carousel({
pause: true,
interval: false
});
});
$('#myCarousel').on('slid', '', function() {
var $this = $(this);
$this.find('.carousel-control').show();
if($('.carousel-inner .item:first').hasClass('active')) {
$this.find('.left.carousel-control').hide();
} else if($('.carousel-inner .item:last').hasClass('active')) {
$this.find('.right.carousel-control').hide();
}
});
</script>
Updated:
As per the way Bootstrap 2.3 carousel works, multiple items like the way you have done won't show 4 items in a row and only one .item class can have an .active class to it, so here's what we would do:
<div class="item active">
<div class="span3"><img></div>
<div class="span3"><img></div>
<div class="span3"><img></div>
<div class="span3"><img></div>
</div>
<div class="item">
<div class="span3"><img></div>
<div class="span3"><img></div>
<div class="span3"><img></div>
<div class="span3"><img></div>
</div>
That's how we are going to structure your elements to look like. So code in:
<!-- code follows -->
<div class="carousel-inner">
<?php
$i = 1;
$next_item = true;
while ($i < 10)
{
if ($i == 1)
{
echo '<div class="item active">';
}
elseif ($next_item == true)
{
echo '<div class="item">';
}
?>
<div class="span3 mef-3">
<!-- code follows -->
</div>
<?php
$next_item = false;
if ($i % 4 == 0)
{
echo '</div>';
$next_item = true;
}
$i++;
}
?>
Also, since you name your carousel as id=myCarousel, your prev and next button's href should be href="#myCarousel" and not href="#textCarousel".
Here's a demo of what it looks like.