Exemplo n.º 1
0
    $conn = new DBCommunication();
    $query = "SELECT * FROM whwp_Advert, whwp_User " . "WHERE whwp_Advert.advert_id = :advert_id " . "AND whwp_User.user_id = whwp_Advert.advert_owner";
    $conn->prepQuery($query);
    $conn->bind('advert_id', $advert_id);
    $resultset = $conn->single();
    $price = $resultset->advert_price;
    $title = $resultset->advert_bookname;
    //$image = $resultset -> image;
    $author = $resultset->advert_bookauthor;
    $user = $resultset->advert_owner;
    $username = $resultset->user_firstname;
    //$description = $resultset -> description;
    $query = "SELECT whwp_Image.image_location FROM whwp_Advert " . "JOIN whwp_AdImage ON whwp_Advert.advert_id = whwp_AdImage.adimage_advert " . "JOIN whwp_Image ON whwp_AdImage.adimage_image = whwp_Image.image_id " . "WHERE whwp_Advert.advert_id = :advert_id";
    $conn->prepQuery($query);
    $conn->bind('advert_id', $advert_id);
    $image = $conn->resultset();
    foreach ($image as $element) {
        echo "<img src = itemPhotos/" . $element->image_location . " alt=" . $title . " title=" . $title . "<br/>";
    }
    echo "Price: " . $price . "<br/>";
    echo "Title: " . $title . "<br/>";
    echo "Author: " . $author . "<br/>";
    // echo "Description: " . $description . "<br/>";
    echo "Posted by: <a href='user.php?user_id={$user}'>" . $username . "</a><br/>";
    echo "<hr/>";
} catch (PDOException $e) {
    echo 'Something went wrong';
}
?>
        <div id="form2">
            <h2>Post a comment:</h2>
Exemplo n.º 2
0
<?php

require 'DBCommunication.php';
header('Content-type: application/json');
$response_array = array('success' => false, 'data' => '');
try {
    $conn = new DBCommunication();
    $query = "SELECT category_id,category_Description FROM whwp_Category";
    $conn->prepQuery($query);
    $response_array['data'] = $conn->resultset();
    $response_array['success'] = true;
} catch (PDOException $e) {
}
echo json_encode($response_array);
Exemplo n.º 3
0
                </ul>
          </div>
          </div>
          </div>
<div class="col-lg-9">
   <div class="panel panel-default">
   <div class="panel-heading">My Books</div>
   <div class="panel-body">
        <?php 
try {
    $conn = new DBCommunication();
    if (isset($_SESSION['user_id'])) {
        $query = "SELECT advert_id,advert_bookname,advert_price FROM whwp_Advert WHERE advert_owner=:user_id AND ((NOT advert_expired=1) OR (advert_expired IS NULL))";
        $conn->prepQuery($query);
        $conn->bind('user_id', $_SESSION['user_id']);
        $result = $conn->resultset();
        echo "<table class=\"table table-hover\">";
        echo "<thead>";
        echo "<tr>";
        echo "<th style=\"width:20%\">ID</th>";
        echo "<th style=\"width:20%\">Title</th>";
        echo "<th style=\"width:20%\">Price</th>";
        echo "<th style=\"width:40%\"></th>";
        echo "</tr>";
        echo "</thead>";
        echo "<tbody>";
        foreach ($result as $item) {
            echo "<tr id='book" . $item->advert_id . "'>";
            echo "<td>" . $item->advert_id . "</td>";
            echo "<td>" . $item->advert_bookname . "</td>";
            echo "<td>" . $item->advert_price . "</td>";
Exemplo n.º 4
0
if (!isset($_SESSION['user_id'])) {
    echo "You need to log in first!";
    header("refresh:3;url=login.php");
} else {
    // Check which user is logged in
    $user_id = $_SESSION['user_id'];
    // Getting messages from the database
    /*$query = "SELECT * FROM message, message_text WHERE :user_id = receiver_id "
      . "AND message.message_id = message_text.message_id";*/
    try {
        // Establishing a connection to the database
        $conn = new DBCommunication();
        $query = "SELECT * FROM whwp_Message WHERE :user_id = message_recipient ORDER BY message_date,message_time DESC";
        $conn->prepQuery($query);
        $conn->bind('user_id', $user_id);
        $message = $conn->resultset();
        $countMessages = $conn->rowCount();
        if ($countMessages == 0) {
            echo "You have no messages in your inbox!";
        } else {
            echo "<table class='table'>";
            echo "<tr><th>Sender</th><th>Title</th>" . "<th>Time Sent</th></tr>";
            foreach ($message as $element) {
                $message_id = $element->message_id;
                $sender_id = $element->message_sender;
                $query = "SELECT user_firstname FROM whwp_User WHERE user_id = :user";
                $conn->prepQuery($query);
                $conn->bind('user', $sender_id);
                $resultset = $conn->single();
                $sender = $resultset->user_firstname;
                $title = $element->message_subject;
Exemplo n.º 5
0
         $page = $_GET["page"];
         $search_term = $_GET["search"];
     } else {
         //$page = 10;
         $page = 1;
         header("location:search.php?search={$search_term}&Search=Search&page=1");
     }
     // Determine which results to show in which page.
     //$start_from = ($page-1) * 10;
     $start_from = ($page - 1) * 10;
     // How many results per one page
     $pageLimit = 10;
     $query = "SELECT DISTINCT whwp_Advert.* FROM whwp_Advert, whwp_AdTag, whwp_Tag " . "WHERE whwp_Tag.tag_description LIKE :search_string " . "AND whwp_Tag.tag_id = whwp_AdTag.adtag_tag " . "AND whwp_AdTag.adtag_advert = whwp_Advert.advert_id " . "ORDER BY whwp_Advert.advert_id " . "LIMIT {$start_from}, {$pageLimit}";
     $conn->prepQuery($query);
     $conn->bind('search_string', $search_string);
     $advert = $conn->resultset();
     foreach ($advert as $element) {
         echo "<p>";
         echo "<a href='showAdvert.php?advert_id=" . $element->advert_id . "'>";
         echo $element->advert_bookname;
         echo "</a>";
         echo " " . $element->advert_price;
         echo "</p>";
     }
     // Determining how many pages will be needed and outputting them.
     $totalPages = ceil($count / $pageLimit);
     for ($i = 1; $i <= $totalPages; $i++) {
         echo "<a href='search.php?search={$search_term}&Search=Search&page={$i}'>{$i}</a> ";
     }
 } catch (PDOException $e) {
     echo 'Something went wrong.';
Exemplo n.º 6
0
     $conn->prepQuery($query);
     $conn->bind('user_id', $user_id);
     $user = $conn->single();
     $username = $user->user_firstname;
     echo "The page of " . $username;
     // Set the target as a private message receiver
     $_SESSION['target_id'] = $user_id;
     // If the user is not in his own page - displaay the link to PM
     if (isset($_SESSION['user_id']) && $_SESSION['user_id'] !== $user_id) {
         echo "<a href='send_message.php'><img src='images/pm.png' id='pm' alt='Private Message' title='Private Message'/></a>";
     }
     // Query to get all the ads from the user, whose page is accessed.
     $query = "SELECT * FROM whwp_Advert WHERE advert_owner = :user_id";
     $conn->prepQuery($query);
     $conn->bind('user_id', $user_id);
     $ad = $conn->resultset();
     $countAds = $conn->rowCount();
     if ($countAds == 0) {
         echo "<br/>No adverts uplaoded by this user!";
     } else {
         echo "<h2>Ads uploaded by: " . $username . ":</h2>";
         foreach ($ad as $element) {
             $advert_id = $element->advert_id;
             $price = $element->advert_price;
             $title = $element->advert_bookname;
             echo "<p><a href ='showAdvert.php?advert_id={$advert_id}'>" . $title . " " . $price . "</a></p>";
         }
     }
 } catch (PDOException $e) {
     echo "Something went wrong.";
 }