我有一个关于If语句的问题,它真的让我发疯。 看来我没有找到合适的解决方案。请让我解释一下情况。 还有4种可能的情况。一个PHP脚本中的IF语句
- 无需出菲林
- 没有图片
- 无需出菲林,但与图片
- 没有画面,但与电影
多一点点的信息,但也许不是必要。 字段电影和图片是数据库中的字段。用PHP脚本,我正在检查一个字段是否填充了某些东西。有了这些信息,我将建立我的页面。在某些情况下,不会有照片或电影的地方。我希望你明白我在说什么。
这是我的代码
<?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>";
}
感谢
你能分享一下你的代码吗? – PeeHaa
@PeeHaa请参阅上面的文章。 – Niels