Advertisement
xtrapsp

player_comments.php

Aug 18th, 2014
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.16 KB | None | 0 0
  1. <?
  2.  
  3. require('header.php');
  4.  
  5. $query=mysqli_query($link,"select email from users");
  6. $email=$link->query($query);    
  7. if(isset($email[0])){    
  8.  $query1=mysqli_query($link,"select id from user where email='".$email[0]."' and facebook=1");
  9.  $admin=$link->query($query1);  
  10.  $userId=$admin[0];
  11. }
  12. if(isset($userId)) {
  13.     /* logged in only */
  14. }
  15.  
  16. $iComments = 0;
  17. $qComments = $db->query("
  18. SELECT songs_comments.*, user.id AS uId, user.username AS uName, user.avatar AS uAvatar
  19. FROM songs_comments LEFT JOIN user ON songs_comments.userid_from = user.id
  20. WHERE songs_comments.songid = '".$rSong->id."' ORDER BY songs_comments.id DESC");
  21. while ($rComments = $qComments->fetch_object()) {
  22.     $showComments .= '
  23.    <img src="../'.makeAvatar($rComments->uId,$rComments->uAvatar,50).'" class="avatar float-left" alt>
  24.    <div class="comment">
  25.        <div class="comment-text">'.$rComments->text.'</div>
  26.        <div class="comment-footer">
  27.            <a href="/">'.$rComments->uName.'</a> on '.dateStamp($rComments->time).'
  28.        </div>
  29.        <br style="clear:both;">
  30.    </div>
  31.    ';
  32.     $iComments++;
  33. } ?>
  34.  
  35.     <script>
  36.         /*wait for the DOM to be loaded
  37.         $(document).ready(function() {
  38.             // bind 'myForm' and provide a simple callback function
  39.             $('#song-comment-form').ajaxForm(function() {
  40.                 alert("Thank you for your comment!");
  41.             });
  42.         }); */
  43.         $(document).ready(function() {
  44.         /*var options = {
  45.             url: 'template/sections/player_comments',
  46.             target: '#player-song-comments', // target element(s) to be updated with server response
  47.             type: 'post' // 'get' or 'post', override for form's 'method' attribute
  48.         };
  49.     $('#song-comment-form').ajaxForm(options); */
  50.             $(document).ready(function() {
  51.             // bind 'myForm' and provide a simple callback function
  52.             $('#song-comment-form').ajaxForm(function() {
  53.                 $("#player-song-comments").load('template/sections/player_comments.php');
  54.                 alert("Thank you for your comment! The site is currently in maintenance and the comment won't show until you revisit this video");
  55.             });
  56.         });
  57. });
  58.     </script>
  59.  
  60. <div id="player-song-comments-wrap">
  61.     <div id="player-song-comments-heading"><img src="template/images/icons/comments.png" alt> Comments</div>
  62.     <div id="player-song-comments-sub-heading">
  63.         <?=isset($userId)?'<a href="/" id="show-song-comment-form" class="float-right">Add comment</a>':'<a href="/register.php" class="modal float-right">Add comment</a>'?>
  64.         <span id="song-comments-num"><?=$iComments?></span> comments for "<span id="song-comments-title"><?=$rSong->title?></span>"
  65.         by <span id="song-comments-artist"><?=$rSong->artist?></span>
  66.     </div>
  67.     <hr>
  68.     <form id="song-comment-form">
  69.         <input type="hidden" value="<?=$rSong->id?>" class="song-id">
  70.         <textarea class="editor" id="song-comment-textarea"></textarea><br>
  71.         <input type="submit" value="Submit"><input type="button" value="Cancel" id="hide-song-comment-form">
  72.         <hr>
  73.     </form>
  74.     <div id="player-song-comments">
  75.         <?=$showComments?>
  76.     </div>
  77. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement