Guest User

Untitled

a guest
Jul 20th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. <?php
  2. #get actual commID from [Comment]
  3. if ($commentUserPrepare1->rowCount()) {
  4. while($ComUserPrep1 = $commentUserPrepare1->fetch(PDO::FETCH_ASSOC)) {
  5. $commentId = $ComUserPrep1['C.commID'];
  6. echo $commentId; // using this for testing only
  7. }
  8. }
  9. else {echo "Error 1.";}
  10. unset($commentUserPrepare1);
  11. ?>
  12.  
  13. <h2 style="margin:0; padding:0;">Recent Comments</h2>
  14. <?php
  15. #display the uname from Student based on commID found above that is inserted into the query
  16. if ($commentUserPrepare2->rowCount()) {
  17. while($ComUserPrep2 = $commentUserPrepare2->fetch(PDO::FETCH_ASSOC)) {
  18. echo "<div class='comment'>by <em>{$ComUserPrep2['uname']}</em> on";
  19. }
  20. }
  21. else {echo "Error 2.";}
  22. unset($commentUserPrepare2);
  23. ?>
  24.  
  25. <?php
  26. #Show Recent Comments
  27. if ($sth2->rowCount()) {
  28. while($row = $sth2->fetch(PDO::FETCH_ASSOC)) {
  29. echo "{$row['date']} about <code><a href='course.php?cID={$row['cID']}'>{$row['prefix']} {$row['code']}</a>&nbsp;</code> during {$row['Qtr']}, {$row['Yr']} <span style='float:right; padding-right:5px;'><img src='img/report.png' />
  30. <a class='report' href='report.php?commID={$row['CommID']}'>Report</a></span><br />{$row['info']} </div>";
  31. }
  32. }
  33. else {
  34. echo "<h2 style='color:red;'> No Comments Found, please add some below</div>";
  35. }
  36. unset($sth2);
  37. ?>
  38.  
  39. // Get any professor comments currently present ON LOAD
  40. $pID2 = filter_input(INPUT_GET, 'pID', FILTER_SANITIZE_NUMBER_INT);
  41. $pdo2 = new PDO('mysql:host=host;dbname=dbname', $u, $p);
  42. $pdo2->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
  43. $sth2 = $pdo2->prepare('
  44. SELECT C.cID, Co.CommID, prefix, code, info, date, Qtr, Yr
  45. FROM Course C, Comment Co, Professor P
  46. WHERE P.pID = ?
  47. AND C.cID = Co.CName AND P.pID = Co.pID
  48. ORDER BY Yr DESC;
  49. ');
  50. $sth2->execute(array(
  51. $pID2
  52. ));
  53.  
  54. ?>
  55. <?php
  56. // Get the commentID of the user
  57. $pID11 = filter_input(INPUT_GET, 'pID', FILTER_SANITIZE_NUMBER_INT);
  58. $commentUser1 = new PDO('mysql:host=host;dbname=dbname', $u, $p);
  59. $commentUser1->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
  60. $commentUserPrepare1 = $commentUser1->prepare("
  61. SELECT C.commID
  62. FROM Professor P, Comment C
  63. WHERE P.pID = ?
  64. AND P.pID = C.pID;
  65. ");
  66. $commentUserPrepare1->execute(array(
  67. $pID11
  68. ));
  69.  
  70. ?>
  71.  
  72.  
  73. <?php
  74. // Get the user of the comment
  75. $pID22 = filter_input(INPUT_GET, 'pID', FILTER_SANITIZE_NUMBER_INT);
  76. $commentUser2 = new PDO('mysql:host=host;dbname=dbname', $u, $p);
  77. $commentUser2->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
  78. $commentUserPrepare2 = $commentUser2->prepare("
  79. SELECT uname FROM Student S, Comment C WHERE S.usrID = C.usrID AND C.commID = '$commentId';
  80. ");
  81. $commentUserPrepare2->execute(array(
  82. $pID22
  83. ));
  84.  
  85. ?>
  86.  
  87. $commentUserPrepare2 = $commentUser2->prepare("
  88. SELECT uname FROM Student S, Comment C WHERE S.usrID = C.usrID AND C.commID = '$commentId';
  89. ");
  90.  
  91. $commentUserPrepare2 = $commentUser2->prepare("
  92. SELECT uname FROM Student S, Comment C WHERE S.usrID = C.usrID;
  93. ");
Add Comment
Please, Sign In to add comment