Skip to content
This repository was archived by the owner on Nov 17, 2017. It is now read-only.

Commit

Permalink
images display
Browse files Browse the repository at this point in the history
  • Loading branch information
tedgavr committed Nov 4, 2017
1 parent d8701a0 commit a703e25
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 35 deletions.
6 changes: 3 additions & 3 deletions Ad.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
require_once 'Buisness/Ad.cls.php';
require_once 'Buisness/dbconfig.php';
require_once 'Buisness/Images.cls.php';
$id = 17;
if(isset($_GET["id"])){
$id = $_GET["id"];
}
Expand All @@ -15,13 +14,14 @@
$image = new Images();
$images = $image->getAll($connectionId);

foreach ($images as $element){
/* foreach ($images as $element){
if($element->getFk_ad_id() == $id){
echo "<div class='image'>";
echo "<img src='".$element->getImagePath()."' alt='".$element->getImagePath()." not found'/>";
echo "</div>";
}
}
}*/
?>

<?php
Expand Down
47 changes: 21 additions & 26 deletions Buisness/Ad.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,26 @@ static function footer1(){
return $res;
}*/
function __toString(){
$db = mysqli_connect("localhost","root","","mydb"); ///added
$var_Id = $this->getPk_ad_id(); ///added
$sql = ("Select distinct ImagePath from Images where fk_ad_id = $var_Id");
$result = mysqli_query($db, $sql);
while ($row = mysqli_fetch_array($result)){
$res="<tr class = 'tr_ad4'><th class = 'td_ad3'>Title:</th><th class = 'td_ad4'>$this->ad_title</th>
<th class = 'td_ad6'>Anonce Number</th><th class = 'td_ad6'>$this->pk_ad_id</th></tr>
<tr class = 'tr_ad5'><th class = 'td_ad5'>Price:</th ><th class = 'td_ad5' colspan = '3'>$this->ad_price</th></tr>
<tr class = 'tr_ad5'><th class = 'td_ad5'>Registration Date:</th><th class = 'td_ad5' colspan = '3'>$this->ad_reg_date</th></tr>
<tr class = 'tr_ad5'><th class = 'td_ad5'>Expiration Date:</th><th class = 'td_ad5' colspan = '3'>$this->ad_exp_date</th></tr>
<tr class = 'tr_ad5'><th class = 'td_ad5'>Description:</th><th class = 'td_ad5'colspan='3'> $this->ad_description </th> </tr>;
<tr class = 'tr_ad5'><th class = 'td_ad7' colspan='3'><div class='pAds'>
<img src ='images/".$row['ImagePath']."' >;
</div></th></tr>";
return $res;
} }
// ----------------Old display----------------
/*//////////////////////////////////////////////////////////////////////////////////////
function __toString(){
$res="<tr class = 'tr_ad4'><th class = 'td_ad3'>Title:</th><th class = 'td_ad4'>$this->ad_title</th>
<th class = 'td_ad6'>Anonce Number</th><th class = 'td_ad6'>$this->pk_ad_id</th></tr>
<tr class = 'tr_ad5'><th class = 'td_ad5'>Price:</th ><th class = 'td_ad5' colspan = '3'>$this->ad_price</th></tr>
Expand All @@ -415,32 +435,7 @@ function __toString(){
<tr class = 'tr_ad5'><th class = 'td_ad5'>Description:</th><th class = 'td_ad5'colspan='3'> $this->ad_description </th> </tr>;
<tr class = 'tr_ad5'><th class = 'td_ad7' colspan='3'><div class='pAds'><img src=.$this->images.</div></th></tr>";
return $res;
}
// ----------------Old display----------------
/*//////////////////////////////////////////////////////////////////////////////////////
* $res="<tr class = 'tr_ad2'>/th class = 'td_ad1' rowspan ='2'><div class='pAds'>
<img src=''.$element->getImages().' alt=''.$element->getImages().' not found' />
<td>'.$element->getAd_price().''</td><td>'.$element->getAd_reg_date().''</td><td>'.$element->getAd_exp_date().''</td></tr>
<tr class = 'tr_ad3'><td>'.$element->getAd_title() .'</td><td colspan = '3'> </td> </tr>";
return $res;
* //////////////////////////////////////////////////////////////////////////////////////
* echo "<br /><tr class = 'tr_ad2'><td class = 'td_ad1' rowspan ='2'><div class='pAds'>";
echo "<img src='".$element->getImages().
"' alt='".$element->getImages()." not found' />";
echo "</div></td ><td><a href='Ad.php?id=".$element->getPk_ad_id()."'>".$element->getAd_description()."</a></td>";
echo "<td>".$element->getAd_price()."</td><td>".$element->getAd_reg_date()."</td><td>".$element->getAd_exp_date()."</td></tr>";
echo "<tr class = 'tr_ad3'><td>".$element->getAd_title() ."</td><td colspan = '3'> </td> </tr>";
echo "<br />";
* //////////////////////////////////////////////////////////////////////////////////////
* static function header(){
$str= "<table border='0'><tr border='1'>";
$str="$str<th>pk_ad_id </th><th>ad_description </th><th>ad_reg_date </th><th>Expiration date </th><th>Payment </th><th>fk_subCat_id </th><th>Price </th><th>Title </th></tr>";
return $str;}
function __toString(){
$res="<tr><td>$this->pk_ad_id</td><td>$this->ad_description</td><td>$this->ad_reg_date</td><td>$this->ad_exp_date</td><td>$this->fk_pay_id</td><td>$this->fk_subCat_id</td><td>$this->ad_price</td><td>$this->ad_title</td></tr>";//
return $res;
}*/
}*/

}
?>
21 changes: 15 additions & 6 deletions Results.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,28 @@

$ad = new Ad(1,$addDesc);
// $isFound = $ad->getPayedAds($connectionId);

$db = mysqli_connect("localhost","root","","mydb"); ///added
$isFound =$ad->search_keyword($connectionId);
echo "The result of search by keywords: ".$addDesc. " <br />";
echo Ad::header();
foreach ($isFound as $element)
{
if($element->getAdIds($connectionId)!=NULL)
{
echo "<br /><tr class = 'tr_ad2'><td class = 'td_ad1' rowspan ='2'><div class='pAds'>";
echo "<img src='".$element->getImages().
"' alt='".$element->getImages()." not found' />";

echo "<br /><tr class = 'tr_ad2'><td class = 'td_ad1' rowspan ='2'><div class='ad_image'>";
/* echo "<img src='".$element->getImages().
"' alt='".$element->getImages()." not found' />";*/
$var_Id = $element->getPk_ad_id(); ///added
$sql = ("Select distinct ImagePath from Images where fk_ad_id = $var_Id");
$result = mysqli_query($db, $sql);
while ($row = mysqli_fetch_array($result)){
// echo "<div id='img_div'>";
echo "<a href='Ad.php?id=".$element->getPk_ad_id()."'>"."<img src ='images/".$row['ImagePath']."' >";
// echo "<p>".$row['fk_ad_id']."</p>";
// echo "</div>"; ///added
}
echo "</div></td ><td><a href='Ad.php?id=".$element->getPk_ad_id()."'>".$element->getAd_description()."</a></td>";
echo "<td>".$element->getAd_price()."</td><td>".$element->getAd_reg_date()."</td><td>".$element->getAd_exp_date()."</td></tr>";
echo "<tr class = 'tr_ad3'><td>".$element->getAd_title() ."</td><td colspan = '3'> </td> </tr>";
Expand All @@ -34,7 +46,4 @@
echo Ad::footer();
}




?>
9 changes: 9 additions & 0 deletions css/Ad.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,13 @@ width:250;
width:250;
text-align:right;
font-size:x-large;
}
.ad_image {
height: 100%;
width: 100%;
// position: center;
float: center;
// display: inline-block;
margin-left: 2%;
background-color: white;
}

0 comments on commit a703e25

Please sign in to comment.