回显带有if语句的元标记?

时间:2018-09-25 06:05:28

标签: php sql if-statement echo

我在数据库中有一列称为entry_type的列,该entry_type仅具有两个可能的值:“ pagina”或“ post”。

我想根据echo的值meta使用不同的entry_type标签。

当我想将entry_type = pagina的值echo放在下面的meta标记中时:

<meta property="og:type" content="website">

如果entry_type = post的值我想echo下面的meta标签:

<meta property="og:type" content="article">
<meta property="article:author" content="">
<meta property="article:publisher" content="" />
<meta property="article:published_time" content="">
<meta property="article:modified_time" content="">

如何做出此if陈述,以执行我的解释?

2 个答案:

答案 0 :(得分:1)

您可以参考以下php代码:

 public Bitmap getBitmapFromUri(Uri uri) {


    if (uri == null || uri.toString().isEmpty())
        return null;

    // Get the dimensions of the View
    int targetW = mImageClick.getWidth();
    int targetH = mImageClick.getHeight();

    InputStream input = null;
    try {
        input = this.getContentResolver().openInputStream(uri);

        // Get the dimensions of the bitmap
        BitmapFactory.Options bmOptions = new BitmapFactory.Options();
        bmOptions.inJustDecodeBounds = true;
        BitmapFactory.decodeStream(input, null, bmOptions);
        input.close();

        int photoW = bmOptions.outWidth;
        int photoH = bmOptions.outHeight;

        // Determine how much to scale down the image
        int scaleFactor = Math.min(photoW / targetW, photoH / targetH);

        // Decode the image file into a Bitmap sized to fill the View
        bmOptions.inJustDecodeBounds = false;
        bmOptions.inSampleSize = scaleFactor;
        bmOptions.inPurgeable = true;

        input = this.getContentResolver().openInputStream(uri);
        Bitmap bitmap = BitmapFactory.decodeStream(input, null, bmOptions);
        input.close();

        return bitmap;

    } catch (FileNotFoundException fne) {
        Log.e(LOG_TAG, "Failed to load image.", fne);
        return null;
    } catch (Exception e) {
        Log.e(LOG_TAG, "Failed to load image.", e);
        return null;
    } finally {
        try {
            input.close();
        } catch (IOException ioe) {

        }
    }
}

答案 1 :(得分:0)

根据您提供的新代码,尝试以下操作

 <?php 
    $row = $mtFB->fetch();
    if ($row['entry_type'] == "pagina") { ?>
        <meta property="og:type" content="website">
    <?php } else  { ?>
        <meta property="og:type" content="article">
        <meta property="article:author" content="">
        <meta property="article:publisher" content="" />
        <meta property="article:published_time" content="">
        <meta property="article:modified_time" content="">
    <?php } ?>