I have a question about a If-statement that is really making me crazy.
It seems that I didn’t find a right solution. Please let me explain the situation.
There are 4 possible situations.
- Without a film
- Without a picture
- Without a film but with a picture
- without a picture but with a film
A little bit more information but maybe not necessary.
The fields film and pictures are fields in a database. With a PHP script, i’m checking if a field is filled with something. With this information i’m going to build my page. In some case there will be no place for a picture, or for a movie for example. I hope you understand what i’m telling.
This is my code
<?php
class Artikel{
public function printWholeArticle()
{
include ('connection.php');
$sSql = "SELECT UNIX_TIMESTAMP(datum) as unixDatum, titel, artikel, id, image, video FROM tblArtikels WHERE id = '" . $this->m_sKey."'";
$res = $mysqli -> query($sSql);
return ($res);
}
}
$key = $_GET['id']; // I get the key from the url
$oNieuwsArtikel = new Artikel();
$oNieuwsArtikel -> Key = $key;
$vAllNieuwsArtikel = $oNieuwsArtikel -> printWholeArticle();
$artikel = $vAllNieuwsArtikel -> fetch_assoc();
// just a part of my if statement, to let you guys know how I print the data to the screen
if ($artikel['image'] == "")
{
echo "<div class='datum'>" . "<div class='day'>" . date('d', $artikel['unixDatum']) . "</div>" . "<div class='month'>" . "/" . date('m', $artikel['unixDatum']) . "</div>" . "<div class='year'>" . date('Y', $artikel['unixDatum']) . "</div>" . "</div>";
echo "<p>" . "<div class='content_wrap_page'>" . "<div class='artikel_page'>"
. "<h1>" . $artikel['titel'] ."</h1>" . $artikel['artikel'] . "</div>" . "</div>" . "</p>";
}
Thanks
Where $film and $picture are set to the value retrieved from the database query.