我一直在试图为此自定义一部分PHP脚本。如果输入值是数字/数字,则显示图像,如果输入值不是数字,则显示文本,如果输入值为0,则不显示任何内容
我希望它显示图像,如果输入值在数字(1,3,20,99或等)。否则,如果输入值是文本(lorem,randomtext等),我希望它显示文本。如果值为0,我希望它不显示任何内容。
但是我一直在弄错。无论输入值是什么,它总是显示文本。
这里是PHP代码:
if ($topic['topic_icon'] = $topic['icon_id'] ) {
if (is_numeric($topic['icon_id'])) {
"<img src='".$ibforums->vars['img_url']."/icon{$topic['icon_id']}.gif' alt='{$topic['icon_id']}' />";
} else {
"<span class='text-icon {$topic['icon_id']}'>{$topic['icon_id']}</span>";
}
} else {
"";
}
这里是用户可以输入值(它与单选按钮,将<form />
标签不包括在内,因为它是大块的一部分HTML的一部分的代码):
<input type="radio" class="radiobutton" name="iconid" value="15" /> <img src="{$ibforums->vars['img_url']}/icon15.gif" align='middle' alt='' />
<input type="radio" class="radiobutton" name="iconid" value="16" /> <img src="{$ibforums->vars['img_url']}/icon16.gif" align='middle' alt='' />
<input type="radio" class="radiobutton" name="iconid" value="17" /> <img src="{$ibforums->vars['img_url']}/icon17.gif" align='middle' alt='' /><br />
<input type="radio" class="radiobutton" name="iconid" value="SPRING" /> <span class='text-icon SPRING'>SPRING</span>
<input type="radio" class="radiobutton" name="iconid" value="SUMMER" /> <span class='text-icon SUMMER'>SUMMER</span>
<input type="radio" class="radiobutton" name="iconid" value="AUTUMN" /> <span class='text-icon AUTUMN'>AUTUMN</span>
<input type="radio" class="radiobutton" name="iconid" value="WINTER" /> <span class='text-icon WINTER'>WINTER</span><br />
<input type="radio" class="radiobutton" name="iconid" value="0" checked="checked" /> [ Use None ]
在MySQL表(它是icon_id
)所用的柱设定为varchar(64)
。
我的长标题道歉......
似乎没有任何区别,即使使用'echo'命令,它仍然显示为文本。并且用==而不是'='使它不显示任何内容.. – deathlock
那么你不能仅仅使用=反正。使IF条件失败!那么你的$ topic数组中有什么? – jtheman
我不确定...我只修改一个PHP脚本,而函数内的其他内容似乎只使用'='。这里是函数:http://pastebin.com/fYk35FEJ我包括我想修改的原始代码。它正在处理原始内容(但它只能显示图像),但它不适用于我的修改。 – deathlock