小编Jam*_*mes的帖子

php if语句检查字段是否为空

可能重复:
如何检查PhP中的mysql条目是否为空?

我试图运行一个看似简单的if语句,但是,我的PHP技能并不是那么好.

我正在查询来自单个MySQL表的数据,并且我想运行一个语句来检测字段是否为空,如果它不是我希望它显示某些东西,如果是,则不显示任何内容.

另外,我不确定是否可以将它置于回声中?

编辑:************************这是让事情变得简单的代码:

我可能做错了什么.这是我的代码,可以更轻松地解释事情

"

if (!$result) {
    exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
//creating the table w/ headers
echo '
<table>
    <thead>
        <tr>
            ...
            <th style="width:90px"><strong><a href="other-items.php?order=oc_retailer">Retailer</a></strong></th>
            <th style="width:90px"><strong>Files</strong></th>
        </tr>
    </thead>';  
// Display each item
  while ($row = mysql_fetch_array($result)) {
  echo '
    <tr>
        ...
        <td style="width:90px">' . $row['oc_retailer'] .'</td>
        <td style="width:90px"> this is where I want to if statement to go</td>


              ';
  }     
  echo '</table>';

  ?>'
Run Code Online (Sandbox Code Playgroud)

php

3
推荐指数
1
解决办法
3万
查看次数

MySQL内联if语句

我有一个查询,从一个表中选择项目的名称,描述,日期等.该表有一个名为"archived"的字段.如果存档字段中的行为1,则表示存档.

我目前在这里使用此代码来显示我的项目列表,无论它是否已存档:

<?php
        // Request the text for zz
        $result = @mysql_query("SELECT oc_sysitem,oc_item,oc_itemdesc,oc_genre,oc_star,oc_alttxt,oc_iearchived,oc_url FROM catalog WHERE oc_sysitem LIKE('zz') ORDER BY oc_sysitem DESC, oc_item, oc_setnum +0 ASC");

        if (!$result) {
            exit('<p>Error performing query: ' . mysql_error() . '</p>');
        }
        //creating the table w/ headers
        echo '
        <table cellpadding="3px">
        <tr>
            <td style="width:360px;font-weight:bold"><p>Title</p></td>
            <td style="width:90px;font-weight:bold"><p>Genre</p></td>
            <td style="width:70px;font-weight:bold"><p>System</p></td>
            <td style="width:51px;font-weight:bold"><p>Rating</p></td>
        </tr>';     
        // Display each zz
        while ($row = mysql_fetch_array($result)) {
        echo '
        <tr title="' . $row['oc_item'] . ' ' . $row['oc_itemdesc'] . ', ' …
Run Code Online (Sandbox Code Playgroud)

php mysql

2
推荐指数
2
解决办法
5164
查看次数

iOS书签图标

我已经能够进行设置,以便在将网站添加到iOS主屏幕时显示正确的图标。它还显示在任何Web浏览器中。但是,当我使用iOS Safari时,请转到该站点,将其书签到书签列表中,图标将显示C。我希望我们的图标显示为与 www.apple.com
www.sunsetwx.com一样, 这是我们正在使用的网站: www.cbcexeter.org

<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=kPgOnJYLYR">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png?v=kPgOnJYLYR">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png?v=kPgOnJYLYR">
<link rel="manifest" href="/manifest.json?v=kPgOnJYLYR">
<link rel="mask-icon" href="/safari-pinned-tab.svg?v=kPgOnJYLYR" color="#bd4c4c">
<link rel="shortcut icon" type="image/png" href="/favicon.png?v=kFginJYoYs">
<meta name="theme-color" content="#ffffff">
Run Code Online (Sandbox Code Playgroud)

我已经尝试过.ico,但是它没有用。

提前致谢。

html ios

2
推荐指数
1
解决办法
3822
查看次数

标签 统计

php ×2

html ×1

ios ×1

mysql ×1