Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- #get actual commID from [Comment]
- if ($commentUserPrepare1->rowCount()) {
- while($ComUserPrep1 = $commentUserPrepare1->fetch(PDO::FETCH_ASSOC)) {
- $commentId = $ComUserPrep1['C.commID'];
- echo $commentId; // using this for testing only
- }
- }
- else {echo "Error 1.";}
- unset($commentUserPrepare1);
- ?>
- <h2 style="margin:0; padding:0;">Recent Comments</h2>
- <?php
- #display the uname from Student based on commID found above that is inserted into the query
- if ($commentUserPrepare2->rowCount()) {
- while($ComUserPrep2 = $commentUserPrepare2->fetch(PDO::FETCH_ASSOC)) {
- echo "<div class='comment'>by <em>{$ComUserPrep2['uname']}</em> on";
- }
- }
- else {echo "Error 2.";}
- unset($commentUserPrepare2);
- ?>
- <?php
- #Show Recent Comments
- if ($sth2->rowCount()) {
- while($row = $sth2->fetch(PDO::FETCH_ASSOC)) {
- echo "{$row['date']} about <code><a href='course.php?cID={$row['cID']}'>{$row['prefix']} {$row['code']}</a> </code> during {$row['Qtr']}, {$row['Yr']} <span style='float:right; padding-right:5px;'><img src='img/report.png' />
- <a class='report' href='report.php?commID={$row['CommID']}'>Report</a></span><br />{$row['info']} </div>";
- }
- }
- else {
- echo "<h2 style='color:red;'> No Comments Found, please add some below</div>";
- }
- unset($sth2);
- ?>
- // Get any professor comments currently present ON LOAD
- $pID2 = filter_input(INPUT_GET, 'pID', FILTER_SANITIZE_NUMBER_INT);
- $pdo2 = new PDO('mysql:host=host;dbname=dbname', $u, $p);
- $pdo2->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
- $sth2 = $pdo2->prepare('
- SELECT C.cID, Co.CommID, prefix, code, info, date, Qtr, Yr
- FROM Course C, Comment Co, Professor P
- WHERE P.pID = ?
- AND C.cID = Co.CName AND P.pID = Co.pID
- ORDER BY Yr DESC;
- ');
- $sth2->execute(array(
- $pID2
- ));
- ?>
- <?php
- // Get the commentID of the user
- $pID11 = filter_input(INPUT_GET, 'pID', FILTER_SANITIZE_NUMBER_INT);
- $commentUser1 = new PDO('mysql:host=host;dbname=dbname', $u, $p);
- $commentUser1->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
- $commentUserPrepare1 = $commentUser1->prepare("
- SELECT C.commID
- FROM Professor P, Comment C
- WHERE P.pID = ?
- AND P.pID = C.pID;
- ");
- $commentUserPrepare1->execute(array(
- $pID11
- ));
- ?>
- <?php
- // Get the user of the comment
- $pID22 = filter_input(INPUT_GET, 'pID', FILTER_SANITIZE_NUMBER_INT);
- $commentUser2 = new PDO('mysql:host=host;dbname=dbname', $u, $p);
- $commentUser2->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
- $commentUserPrepare2 = $commentUser2->prepare("
- SELECT uname FROM Student S, Comment C WHERE S.usrID = C.usrID AND C.commID = '$commentId';
- ");
- $commentUserPrepare2->execute(array(
- $pID22
- ));
- ?>
- $commentUserPrepare2 = $commentUser2->prepare("
- SELECT uname FROM Student S, Comment C WHERE S.usrID = C.usrID AND C.commID = '$commentId';
- ");
- $commentUserPrepare2 = $commentUser2->prepare("
- SELECT uname FROM Student S, Comment C WHERE S.usrID = C.usrID;
- ");
Add Comment
Please, Sign In to add comment