我在数据库中有一列称为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
陈述,以执行我的解释?
答案 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 } ?>