why the comment is not displayed? - javascript

I need help on this I don't know if it a mistake here because the comment is not displayed, I submit the comment and I see it in the database but it's doesn't show on unfortunately.
popuptweets.php
<?php
include '../init.php';
if (isset($_POST['showpopup']) && !empty($_POST['showpopup'])) {
$tweetID = $_POST['showpopup'];
$user_id = $_SESSION['user_id'];
$tweet = $getFromT->getPopupTweet($tweetID);
$user = $getFromU->userData($user_id);
$likes = $getFromT->likes($user_id, $tweetID);
$retweet = $getFromT->checkRetweet($tweetID, $user_id);
$comments = $getFromT->comments($tweetID);
?>
<div class="tweet-show-popup-wrap">
<input type="checkbox" id="tweet-show-popup-wrap">
<div class="wrap4">
<label for="tweet-show-popup-wrap">
<div class="tweet-show-popup-box-cut">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
</label>
<div class="tweet-show-popup-box">
<div class="tweet-show-popup-inner">
<div class="tweet-show-popup-head">
<div class="tweet-show-popup-head-left">
<div class="tweet-show-popup-img">
<img src="<?php echo BASE_URL.$tweet->profileImage;?>"/>
</div>
<div class="tweet-show-popup-name">
<div class="t-s-p-n">
<a href="<?php echo BASE_URL.$tweet->username;?>">
<?php echo $tweet->screenName;?>
</a>
</div>
<div class="t-s-p-n-b">
<a href="<?php echo BASE_URL.$tweet->username;?>">
#<?php echo $tweet->username;?>
</a>
</div>
</div>
</div>
<div class="tweet-show-popup-head-right">
<button class="f-btn"><i class="fa fa-user-plus"></i> Follow </button>
</div>
</div>
<div class="tweet-show-popup-tweet-wrap">
<div class="tweet-show-popup-tweet">
<?php echo $getFromT->getTweetLinks($tweet->status);?>
</div>
<div class="tweet-show-popup-tweet-ifram">
<?php if(!empty($tweet->tweetImage)){?>
<img src="<?php echo BASE_URL.$tweet->tweetImage;?>"/>
<?php }?>
</div>
</div>
<div class="tweet-show-popup-footer-wrap">
<div class="tweet-show-popup-retweet-like">
<div class="tweet-show-popup-retweet-left">
<div class="tweet-retweet-count-wrap">
<div class="tweet-retweet-count-head">
RETWEET
</div>
<div class="tweet-retweet-count-body">
<?php echo $tweet->retweetCount;?>
</div>
</div>
<div class="tweet-like-count-wrap">
<div class="tweet-like-count-head">
LIKES
</div>
<div class="tweet-like-count-body">
<?php echo $tweet->likesCount;?>
</div>
</div>
</div>
<div class="tweet-show-popup-retweet-right">
</div>
</div>
<div class="tweet-show-popup-time">
<span><?php echo $tweet->postedOn;?></span>
</div>
<div class="tweet-show-popup-footer-menu">
<ul>
<?php if($getFromU->loggedIn() === true){
echo '<li><i class="fa fa-share" aria-hidden="true"></i></a></button></li>
<li>'.(($tweet->tweetID === $retweet['retweetID']) ? '<button class="retweeted" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><a href="#"><i class="fa fa-retweet" aria-hidden="true"></i><span class="retweetsCount">'.$tweet->retweetCount.'</span></button>' : '<button class="retweet" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><a href="#"><i class="fa fa-retweet" aria-hidden="true"></i><span class="retweetsCount">'.(($tweet->retweetCount > 0) ? $tweet->retweetCount : '').'</span></button>').'</li>
<li>'.(($likes['likeOn'] === $tweet->tweetID) ? '<button class="unlike-btn" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><i class="fa fa-heart-o" aria-hidden="true"></i><span class="likesCounter">'.$tweet->likesCount.'</span></button>' : '<button class="like-btn" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><i class="fa fa-heart" aria-hidden="true"></i><span class="likesCounter">'.(($tweet->likesCount > 0) ? $tweet->likesCount : '').'</span></button>').'</li>
<li>
<i class="fa fa-ellipsis-h" aria-hidden="true"></i>
<ul>
<li><label class="deleteTweet">Delete Tweet</label></li>
</ul>
</li>';
}else{
?>
<li><button type="buttton"><i class="fa fa-share" aria-hidden="true"></i></button></li>
<li><button type="button"><i class="fa fa-retweet" aria-hidden="true"></i><span class="retweetsCount">RETWEET-COUNT</span></button></li>
<li><button type="button"><i class="fa fa-heart" aria-hidden="true"></i><span class="likesCount">LIKES-COUNT</span></button></button></li>
<?php }?>
</ul>
</div>
</div>
</div><!--tweet-show-popup-inner end-->
<?php if($getFromU->loggedIn() === true){?>
<div class="tweet-show-popup-footer-input-wrap">
<div class="tweet-show-popup-footer-input-inner">
<div class="tweet-show-popup-footer-input-left">
<img src="<?php echo BASE_URL.$user->profileImage?>"/>
</div>
<div class="tweet-show-popup-footer-input-right">
<input id="commentField" type="text" data-tweet="<?php echo $tweet->tweetID;?>" name="comment" placeholder="Reply to #<?php echo $tweet->username;?>">
</div>
</div>
<div class="tweet-footer">
<div class="t-fo-left">
<ul>
<li>
<label for="t-show-file"><i class="fa fa-camera" aria-hidden="true"></i></label>
<input type="file" id="t-show-file">
</li>
<li class="error-li">
</li>
</ul>
</div>
<div class="t-fo-right">
<span id="count">140</span>
<input type="submit" id="postComment" value="Tweet">
<script type="text/javascript" src="<?php echo BASE_URL;?>assets/js/comment.js"></script>
</div>
</div>
</div><!--tweet-show-popup-footer-input-wrap end-->
<?php }?>
<div class="tweet-show-popup-comment-wrap">
<div id="comments">
<?php
foreach ((array)$comments as $comment) {
echo '<div class="tweet-show-popup-comment-box">
<div class="tweet-show-popup-comment-inner">
<div class="tweet-show-popup-comment-head">
<div class="tweet-show-popup-comment-head-left">
<div class="tweet-show-popup-comment-img">
<img src="'.BASE_URL.$comment->profileImage.'">
</div>
</div>
<div class="tweet-show-popup-comment-head-right">
<div class="tweet-show-popup-comment-name-box">
<div class="tweet-show-popup-comment-name-box-name">
'.$comment->screenName.'
</div>
<div class="tweet-show-popup-comment-name-box-tname">
#'.$comment->username.' - '.$comment->commentAt.'
</div>
</div>
<div class="tweet-show-popup-comment-right-tweet">
<p>#'.$tweet->username.' '.$comment->comment.'</p>
</div>
<div class="tweet-show-popup-footer-menu">
<ul>
<li><button><i class="fa fa-share" aria-hidden="true"></i></button></li>
<li><i class="fa fa-heart-o" aria-hidden="true"></i></li>
<li>
<i class="fa fa-ellipsis-h" aria-hidden="true"></i>
<ul>
<li><label class="deleteTweet">Delete Tweet</label></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
<!--TWEET SHOW POPUP COMMENT inner END-->
</div>
';
}
?>
</div>
</div>
<!--tweet-show-popup-box ends-->
</div>
</div>
<?php
}
?>
comment.js
$(function () {
$(document).on('click', '#postComment', function(){
var comment = $('#commentField').val();
var tweet_id = $('#commentField').data('tweet');
if(comment !=""){
$.post('http://localhost/twitter/core/ajax/comment.php', {comment:comment,tweet_id:tweet_id}, function(data){
$('#comments').html(data);
$('#commentField').val("");
});
}
})
});
commnet.php
<?php
include '../init.php';
if (isset($_POST['comment']) && !empty($_POST['comment'])) {
$comment = $getFromU->checkInput($_POST['comment']);
$user_id = $_SESSION['user_id'];
$tweetID = $_POST['tweet_id'];
if (!empty($comment)) {
$getFromU->create('comments',array('comment' => $comment, 'commentOn' => $tweetID, 'commentBy' => $user_id, 'commentAt' => date('Y-m-d H:i:s')));
$comments = $getFromT->comments($tweetID);
$tweet = $getFromT->getPopupTweet($tweetID);
foreach ((array)$comments as $comment) {
echo '<div class="tweet-show-popup-comment-box">
<div class="tweet-show-popup-comment-inner">
<div class="tweet-show-popup-comment-head">
<div class="tweet-show-popup-comment-head-left">
<div class="tweet-show-popup-comment-img">
<img src="'.BASE_URL.$comment->profileImage.'">
</div>
</div>
<div class="tweet-show-popup-comment-head-right">
<div class="tweet-show-popup-comment-name-box">
<div class="tweet-show-popup-comment-name-box-name">
'.$comment->screenName.'
</div>
<div class="tweet-show-popup-comment-name-box-tname">
#'.$comment->username.' - '.$comment->commentAt.'
</div>
</div>
<div class="tweet-show-popup-comment-right-tweet">
<p>#'.$tweet->username.' '.$comment->comment.'</p>
</div>
<div class="tweet-show-popup-footer-menu">
<ul>
<li><button><i class="fa fa-share" aria-hidden="true"></i></button></li>
<li><i class="fa fa-heart-o" aria-hidden="true"></i></li>
<li>
<i class="fa fa-ellipsis-h" aria-hidden="true"></i>
<ul>
<li><label class="deleteTweet">Delete Tweet</label></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
<!--TWEET SHOW POPUP COMMENT inner END-->
</div>
';
}
}
}
?>
Those are all codes I used so how can I solve the problem?

As we have investigated the problem was in missing return

Related

Find closest div on onclick and append the div

Here i want to append the div to the parent div using closest function.Here is my code please have a look
var maxAppends = 0;
function add_field(id)
{
var update_new = $('<div class="form-group" style="margin-bottom: 0px">\n\
<label for="field-1" class="col-sm-4 control-label">Documentsss</label>\n\
<div class="col-sm-5">\n\
<div class="fileinput fileinput-new" data-provides="fileinput">\n\
<span class="btn btn-default btn-file"><span class="fileinput-new" >Select file</span><span class="fileinput-exists" >Change</span><input type="file" name="files[]" ></span> <span class="fileinput-filename"></span>×</div></div>\n\<div class="col-sm-2">\n\<strong>\n\
<i class="fa fa-times"></i> Remove</strong></div>');
$(".update_new_"+id).append(update_new);
maxAppends++;
}
<div id="update_new_<?php echo $value->id;?>" class="update_new_<?php echo $value->id;?> item-row">
<div class="form-group mb0" style="margin-bottom: 0px">
<label for="field-1"
class="col-sm-4 control-label">Other Document</label>
<div class="col-sm-5">
<div class="fileinput fileinput-new" data-provides="fileinput">
<?php
if (!empty($value->documents)) {
$uploaded_file = json_decode($value->documents);
}
if (!empty($uploaded_file)):foreach ($uploaded_file as $v_files_image): ?>
<div class="">
<input type="hidden" name="fileName[]"
value="<?php echo $v_files_image ?>">
<span class=" btn btn-default btn-file">
<span class="fileinput-filename"> <?php echo $v_files_image ?></span>
×
</span>
<strong>
<a href="javascript:void(0);" class="RCF"><i
class="fa fa-times"></i> Remove</a></strong>
<p></p>
</div>
<?php endforeach; ?>
<?php else: ?>
<span class="btn btn-default btn-file"><span
class="fileinput-new">Select File</span>
<span class="fileinput-exists"><?= lang('change') ?></span>
<input type="file" name="files[]">
</span>
<span class="fileinput-filename"></span>
<a href="#" class="close fileinput-exists" data-dismiss="fileinput"
style="float: none;">×</a>
<?php endif; ?>
</div>
<div id="msg_pdf" style="color: #e11221"></div>
</div>
<div class="col-sm-3">
<strong><a href="javascript:void(0);" id="update_more" onclick="add_field('<?php echo $value->id;?>');" u_id="<?php echo $value->id;?>" class="addCF item-row-click update_more_<?php echo $value->id;?>"><i
class="fa fa-plus"></i> Add More
</a></strong>
</div>
</div>
</div>
when i click add_field i want a div to append to the parent div with class update_new_<?php echo $value->id;?>,so in order to that i had done a script.please have a look
without using closest function the div is appending but the values of div is not passing the value through post,so i want to do the append function with closest function,please help me to solve

Displaying text using php echo with innerhtml inside a data-filter

I have attempted to inject php instead of text as innerhtml using 'onclick' This script appears in the 'head' of my website. I have a data-filter to display images under categories. 'onclick' the images are displayed. Underneath the images the php as text should appear - a heading for the category and description underneath. If left as straight innerhtml this all works. It is the php echo that doesn't. I really would like this to work so that the heading and description can be managed from the CMS (database).
1[this is an example of the type of image display] http://bootstraplovers.com/assan-kit-v3.7/bootstrap4/website-templates/classic-template/html/folio-mosaic-full.html)<
<!-- script for product category and description -->
<script>
function clearText(){ //clears all TEXT when ALL link clicked
document.getElementById('productCategoryName').innerHTML="";
document.getElementById('productDescription').innerHTML="";
}
function getDetails_Propagation(){ //get details for Propagation products when PROPAGATION link clicked
<?php
$query = "SELECT * FROM tbl_product WHERE product_categoryID=4";
$result = mysqli_query($link, $query);
while ($row = mysqli_fetch_array($result)) {
extract($row);
?>
document.getElementById('productCategoryName').innerHTML="<?php echo $row['product_categoryName']; ?>";
document.getElementById('productDescription').innerHTML="<?php echo $row['description']; ?>";
<?php
} //end of while
?>
}
function getDetails_Ventilation(){ //get details for Ventilation products when VENTILATION link clicked
<?php
$query = "SELECT * FROM tbl_product WHERE product_categoryID=7";
$result = mysqli_query($link, $query);
while ($row = mysqli_fetch_array($result)) {
extract($row);
?>
document.getElementById('productCategoryName').innerHTML="<?php echo $row['product_categoryName']; ?>";
document.getElementById('productDescription').innerHTML="<?php echo $row['description']; ?>";
<?php
} //end of while
?>
}
function getDetails_Heaters(){ //get details for Heaters products when HEATERS link clicked
<?php
$query = "SELECT * FROM tbl_product WHERE product_categoryID=8";
$result = mysqli_query($link, $query);
while ($row = mysqli_fetch_array($result)) {
extract($row);
?>
document.getElementById('productCategoryName').innerHTML="<?php echo $row['product_categoryName']; ?>";
document.getElementById('productDescription').innerHTML="<?php echo $row['description']; ?>";
<?php
} //end of while
?>
}
function getDetails_Screens(){ //get details for Screens products when SCREENS link clicked
<?php
$query = "SELECT * FROM tbl_product WHERE product_categoryID=6";
$result = mysqli_query($link, $query);
while ($row = mysqli_fetch_array($result)) {
extract($row);
?>
document.getElementById('productCategoryName').innerHTML="<?php echo $row['product_categoryName']; ?>";
document.getElementById('productDescription').innerHTML="<?php echo $row['description']; ?>";
<?php
} //end of while
?>
}
</script>
</head>
<body>
<ul class="filter list-inline">
<li><a class="active" href="#" data-filter="*" onclick="clearText()">Show All</a></li>
<li>Propagation</li>
<li>Ventilation</li>
<li>Heaters</li>
<li>Screens</li>
</ul>
<div class="portfolio-box iso-call col-5-no-space">
<div class="project-post branding">
<div class="img-icon">
<img src="images/products/Heaters_1.jpg" class="img-responsive" alt="heaters">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post web-design">
<div class="img-icon">
<img src="images/products/screen1.jpg" class="img-responsive" alt="screens">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post web-design">
<div class="img-icon">
<img src="images/products/screen2.jpg" class="img-responsive" alt="screens">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post web-design">
<div class="img-icon">
<img src="images/products/screen3.jpg" class="img-responsive" alt="screens">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post branding">
<div class="img-icon">
<img src="images/products/Heaters_2.jpg" class="img-responsive" alt="heaters">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post END ROW ONE-->
<div class="project-post illustration">
<div class="img-icon">
<img src="images/products/Ventilation_extractorFan1.jpg" class="img-responsive" alt="ventilation">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post branding">
<div class="img-icon">
<img src="images/products/Heaters_3.jpg" class="img-responsive" alt="heaters">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post web-design">
<div class="img-icon">
<img src="images/products/screen4.jpg" class="img-responsive" alt="screens">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post web-design">
<div class="img-icon">
<img src="images/products/screen5.jpg" class="img-responsive" alt="screens">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post web-design">
<div class="img-icon">
<img src="images/products/screen6.jpg" class="img-responsive" alt="">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post END ROW TWO-->
<div class="project-post photography">
<div class="img-icon">
<img src="images/products/propagation_armMistController.jpg" class="img-responsive" alt="">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post photography">
<div class="img-icon">
<img src="images/products/propagation_thermostat.jpg" class="img-responsive" alt="propagation">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post photography">
<div class="img-icon">
<img src="images/products/propagation_armMistController2.jpg" class="img-responsive" alt="propagation">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post photography">
<div class="img-icon">
<img src="images/products/propagation_soilwarmingCable.jpg" class="img-responsive" alt="propagation">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post illustration">
<div class="img-icon">
<img src="images/products/Ventilation_extractorFan2.jpg" class="img-responsive" alt="ventiliation">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post END ROW THREE-->
<div class="project-post photography">
<div class="img-icon">
<img src="images/products/propagation_soilwarmingCable2.jpg" class="img-responsive" alt="propagation">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post illustration ">
<div class="img-icon">
<img src="images/products/Ventilation_airInlet1.jpg" class="img-responsive" alt="ventilation">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post photography">
<div class="img-icon">
<img src="images/products/propagation_thermostat2.gif" class="img-responsive" alt="propagation">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post photography">
<div class="img-icon">
<img src="images/products/propagation_thermostat3.gif" class="img-responsive" alt="propagation">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post illustration">
<div class="img-icon">
<img src="images/products/Ventilation_airInlet2.jpg" class="img-responsive" alt="ventilation">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post END ROW FOUR-->
<div class="project-post illustration">
<div class="img-icon">
<img src="images/products/Ventilation_airInlet3.jpg" class="img-responsive" alt="ventilation">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post illustration ">
<div class="img-icon">
<img src="images/products/Ventilation_extractorFan3.jpg" class="img-responsive" alt="ventilation">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post illustration">
<div class="img-icon">
<img src="images/products/Ventilation_stirrerFan1.jpg" class="img-responsive" alt="ventilation">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post illustration">
<div class="img-icon">
<img src="images/products/Ventilation_stirrerFan2.jpg" class="img-responsive" alt="ventilation">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post-->
<div class="project-post illustration">
<div class="img-icon">
<img src="images/products/Ventilation_stirrerFan3.jpg" class="img-responsive" alt="ventilation">
<div class="img-icon-overlay">
<p>
<i class="fa fa-eye"></i>
<i class="fa fa-sliders"></i>
</p>
</div>
</div> <!--img-icon-->
</div><!--project post END ROW FIVE-->
</div>
</div> <!--end portfolio-box-->
<!-- product category details -->
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="blog-post">
<h2 id="productCategoryName"></h2> <!-- function in head -->
<p id="productDescription"></p> <!-- function in head -->
</div><!--blog post-->
</div><!--end col-->
</div><!--row for blog post-->
</div> <!--full width-->
</div> <!--end container-->
</body>
I don't have reputation to write comment try this
<?php echo "<script>document.getElementById('productCategoryName').innerHTML=". $row['product_categoryName']."</script>" ?>
i hope this code for learning only and not for actual production.
i hope this help you !

passing a unique variable inbetween url

i have a software which passed a unique id to the url of my clients but limitation of my software is that is passes the unique id in the end of the url and sometimes link are too long and we want to pass id inbetween the url like www.zyx.com?id=i want to pass id here in between &jsabdkhbdf&sdkjbahdb&kjdsbkfbskdb&pid=jdndhf
i have seeen a software where is you to pass id in between you type like this ?id=[%id%] where every in url i type this parameter will pass there idk how its hapenning there pls help pasting the code
<?php require_once("session.php" );?>
<?php include("header.php"); require_once("dbcon.php");?>
<div class="navbar-default sidebar" role="navigation">
<div class="sidebar-nav navbar-collapse">
<ul class="nav" id="side-menu">
<li class="sidebar-search">
<div class="input-group custom-search-form">
<input type="text" class="form-control" placeholder="Search...">
<span class="input-group-btn">
<button class="btn btn-default" type="button">
<i class="fa fa-search"></i>
</button>
</span>
</div>
</li>
<li>
<i class="fa fa-dashboard fa-fw"></i> Dashboard<br>
</li>
<li>
<i class="fa fa-bar-chart-o fa-fw"></i> Survey<span class="fa arrow"></span>
<ul class="nav nav-second-level">
<li>
New Survey
Add Clients
Clients List
</li>
<li>
Survey List
</li>
</ul>
<!-- /.nav-second-level -->
</li><br>
<li>
<i class="fa fa-table fa-fw"></i>Add Vendor
Vendor List
</li>
<li>
<!-- /.nav-second-level -->
</li>
</ul>
</div>
<!-- /.sidebar-collapse -->
</div>
<!-- /.navbar-static-side -->
<nav>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-8 ">
<h1 class="page-header">Dashboard</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
<div class="col-lg-3 col-md-6">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-check-circle fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<?php
$sql = "SELECT COUNT(status) as count from new_survey WHERE Status LIKE 'open%'";
$result = $conn->query($sql);
while($rows = $result->fetch_assoc() )
echo "<div class='huge'>{$rows['count']}</div>";
?>
<div>Surveys Completed</div>
</div>
</div>
</div>
<a href="#">
<div class="panel-footer">
<span class="pull-left">View Details</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
</div>
<div class="col-lg-3 col-md-6">
<div class="panel panel-green">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-tasks fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge">New</div>
<div>Survey</div>
</div>
</div>
</div>
<a href="new_survey.php">
<div class="panel-footer">
<span class="pull-left">Create New Survey</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
</div>
<div class="col-lg-3 col-md-6">
<div class="panel panel-yellow">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-ban fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<?php
$sql = "SELECT COUNT(status) as count from new_survey WHERE Status LIKE 'close%'";
$result = $conn->query($sql);
while($rows = $result->fetch_assoc() )
echo "<div class='huge'>{$rows['count']}</div>";
?>
<div>InCompleted Surveys</div>
</div>
</div>
</div>
<a href="#">
<div class="panel-footer">
<span class="pull-left">View Details</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
</div>
<div class="col-lg-3 col-md-6">
<div class="panel panel-red">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-support fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<?php
$sql = "SELECT COUNT(status) as count from new_survey WHERE Status LIKE 'invoice%'";
$result = $conn->query($sql);
while($rows = $result->fetch_assoc() )
echo "<div class='huge'>{$rows['count']}</div>";
?>
<div>Invoiced Surveys</div>
</div>
</div>
</div>
<a href="#">
<div class="panel-footer">
<span class="pull-left">View Details</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
Survey List
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" width="100%" border="1">
<thead><tr>
<th>Survey ID</th>
<th>Client Name</th>
<th>Survey Name</th>
<th>Client Live URL</th>
<th>Client Test URL</th>
<th>Completed</th>
<th>InCompleted</th>
<th>Quota Full</th>
<th>Time Period</th>
<th>Creation Date</th>
<th>End Date</th>
<th>Status</th>
<th>Edit</th>
</tr>
</thead>
<tbody>
<?php
**this is unique parameter**
**$a = bin2hex(random_bytes(10));**
$sql = "SELECT * from new_survey where survey_id order by survey_id desc";
$result = $conn->query($sql);
while($rows = $result->fetch_assoc() ){
echo "<tr>";
echo " <td>{$rows['survey_id']}</td>";
echo " <td>{$rows['client_name']}</td>";
echo "<td>{$rows['survey_name']}</td>";
here it is passing when fetching the url from database onclick of link
**echo "<td> <a href=". $rows['client_live_url'] . urlencode($a) . "&s_id=" . $rows['survey_id'] . " target='_blank'> Click Here </a></td>";**
echo "<td> Click Here </td>";
echo" <td>{$rows['completed']}</td>";
echo "<td>{$rows['incompleted']}</td>";
echo "<td>{$rows['quota_full']}</td>";
echo" <td>{$rows['time_period']}</td>";
echo" <td>{$rows['creation_date']}</td>";
echo" <td>{$rows['end_date']}</td>";
echo" <td>{$rows['status']}</td>";
echo" <td><a href=\"edit_survey.php?id={$rows['survey_id']}\">Edit</td>";
echo "</tr>";
}
$conn->close();
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- /#page-wrapper -->
<div class="panel-footer">
<div class="text-center">
<?php echo date('Y'); ?>, ©
<?php echo "$copyright"; ?>
</div>
</div>
<!-- /#wrapper -->
<!-- jQuery -->
<script src="./vendor/jquery/jquery.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="./vendor/bootstrap/js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="./vendor/metisMenu/metisMenu.min.js"></script>
<!-- Morris Charts JavaScript -->
<script src="./vendor/raphael/raphael.min.js"></script>
<script src="./vendor/morrisjs/morris.min.js"></script>
<script src="./data/morris-data.js"></script>
<!-- Custom Theme JavaScript -->
<script src="./dist/js/sb-admin-2.js"></script>

Class "active" does not work

In my project I'm using accordion, but the "active" state only works in the click event. I need it to work when active. When active, it shows the minus sign and plus sign when not active. I am using ACF in Wordpress.
My PHP code:
<div class="accordian-boxed"><br>
<?php if(get_field('bio_bl2_accordion')):
$dig_count=0; ?>
<ul class="accordion-box">
<?php while(has_sub_field('bio_bl2_accordion')):
if ($dig_count == 0) { ?>
<li class="accordion block">
<div class="acc-btn">
<div class="icon-outer">
<span class="icon icon-plus fa fa-plus"></span>
<span class="icon icon-minus fa fa-minus"></span>
</div>
<?php the_sub_field('ac_titulo');?>
</div>
<div class="acc-content current">
<div class="content">
<div class="text">
<p><?php the_sub_field('ac_descricao');?></p>
</div>
</div>
</div>
</li>
<?php } else {?>
<li class="accordion block">
<div class="acc-btn">
<div class="icon-outer">
<span class="icon icon-plus fa fa-plus"></span>
<span class="icon icon-minus fa fa-minus"></span>
</div>
<?php the_sub_field('ac_titulo');?>
</div>
<div class="acc-content">
<div class="content">
<div class="text">
<p><?php the_sub_field('ac_descricao');?></p>
</div>
</div>
</div>
</li>
<?php }
$dig_count++; ?>
<?php endwhile; ?>
</ul>
<?php else : endif; ?>
My JS code:
if($('.accordion-box').length){
$('.accordion-box').on('click', '.acc-btn', function() {
var target = $(this).parents('.accordion');
if($(this).hasClass('active')!==true){
$('.accordion .acc-btn').removeClass('active');
}
if ($(this).next('.acc-content').is(':visible')){
//$(this).removeClass('active');
return false;
//$(this).next('.accord-content').slideUp(300);
}else{
$(this).addClass('active');
$('.accordion').removeClass('active-block');
$('.accordion .acc-content').slideUp(300);
target.addClass('active-block');
$(this).next('.acc-content').slideDown(300);
}
});
}
See the image:
The icons state image
Can someone help me?
Thanks

Hide #go_to_top icon when box is clicked

I have this chat box and this go_to_top icon. Is that possible to hide the icon when the box is clicked and open, and display it again when its closed?
This is how it looks in my local host (view extern):
This my ChatBox code
<section class="btn-xs bd-section-5 hidden-xs bd-page-width bd-tagstyles" id="section5" data-section-title="Section">
<div class="bd-container-inner bd-margins clearfix">
<div class=" bd-layoutbox-9 bd-page-width bd-no-margins clearfix">
<div type="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" class="chatbutton bd-container-inner btn btn-default">
<h4 class=" bd-textblock-11 bd-content-element">
<span style="font-weight: normal;">Call us on</span> 0800 0125 888
</h4>
</div>
<div class="panel-collapse collapse" id="collapseOne">
<div class="panel-body">
<ul class="chat">
<li class="left clearfix"><span class="chat-img pull-left">
<img src="./assets/images/<?php echo ($cruise_avatar[0]); ?>.png" alt="<?php echo ($cruise_avatar[0]); ?>" class="img-circle" />
</span>
<div class="chat-body clearfix">
<div class="header">
<strong class="primary-font"><?php echo ($cruise_avatar[1]); ?></strong> <small class="pull-right text-muted">
<span class="glyphicon glyphicon-time"></span><?php echo date("h:i:s A"); ?></small>
</div>
<p>
<?php echo ($cruise_avatar[2]); ?>
</p>
</div>
</li>
<li class="right clearfix"><span class="chat-img pull-right">
<img src="http://placehold.it/50/FA6F57/fff&text=ME" alt="User Avatar" class="img-circle" />
</span>
<div class="chat-body clearfix">
<div class="header">
<small class=" text-muted"><span class="glyphicon glyphicon-time"></span><?php echo date("h:i:s A"); ?></small>
<strong class="pull-right primary-font">Bhaumik Patel</strong>
</div>
<p>
<?php echo ($cruise_avatar[2]); ?>
</p>
</div>
</li>
</ul>
</div>
<div class="panel-footer">
<div class="input-group">
<input id="btn-input" type="text" class="form-control input-sm" placeholder="Type your message here..." />
<span class="input-group-btn">
<button class="btn btn-warning btn-sm" id="btn-chat">
Send</button>
</span>
</div>
</div>
</div>
</div>
</div>
</section>
And that's it looks like this when clicked (view extern):
I tried to hide it with jQuery like this: UPDATE it to
<script>
$(document).ready(function(){
$(".bd-layoutbox-9").click(function(){
if ($("span.bd-icon-67.bd-icon").css("display","inline-block")){
$("span.bd-icon-67.bd-icon").css("display","none");
}
else if ($("span.bd-icon-67.bd-icon").css("display","none")){
$("span.bd-icon-67.bd-icon").css("display","inline-block");
}
});
});
</script>
and my span code
<div data-smooth-scroll data-animation-time="250" class=" bd-smoothscroll-3">
<span class="bd-icon-67 bd-icon "></span>
</div>
I can hide it when Chatbox is open, but when i close it is not displayed again.

Categories

Resources