Note that there are some explanatory texts on larger screens.

plurals
  1. POIF statement in a PHP script
    primarykey
    data
    text
    <p>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 <strong>4 possible situations</strong>. </p> <ol> <li>Without a film </li> <li>Without a picture</li> <li>Without a film but with a picture</li> <li>without a picture but with a film </li> </ol> <p><em>A little bit more information but maybe not necessary.</em> 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. </p> <p><strong>This is my code</strong></p> <pre><code>&lt;?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-&gt;m_sKey."'"; $res = $mysqli -&gt; query($sSql); return ($res); } } $key = $_GET['id']; // I get the key from the url $oNieuwsArtikel = new Artikel(); $oNieuwsArtikel -&gt; Key = $key; $vAllNieuwsArtikel = $oNieuwsArtikel -&gt; printWholeArticle(); $artikel = $vAllNieuwsArtikel -&gt; 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 "&lt;div class='datum'&gt;" . "&lt;div class='day'&gt;" . date('d', $artikel['unixDatum']) . "&lt;/div&gt;" . "&lt;div class='month'&gt;" . "/" . date('m', $artikel['unixDatum']) . "&lt;/div&gt;" . "&lt;div class='year'&gt;" . date('Y', $artikel['unixDatum']) . "&lt;/div&gt;" . "&lt;/div&gt;"; echo "&lt;p&gt;" . "&lt;div class='content_wrap_page'&gt;" . "&lt;div class='artikel_page'&gt;" . "&lt;h1&gt;" . $artikel['titel'] ."&lt;/h1&gt;" . $artikel['artikel'] . "&lt;/div&gt;" . "&lt;/div&gt;" . "&lt;/p&gt;"; } </code></pre> <p>Thanks </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload