-3

Can you tell me why my IF don't work? I'm referring to this: if(!$row[12] == ''); In MySQL: $row[12] have value ''. I was tring any method I know, but none work.

<?php
$nazwa = addSecurity($_GET['mod']);
$result = mysql_query("SELECT * FROM mods WHERE sytemname='$nazwa'");

while ($row = mysql_fetch_row($result)) {
 if(!$row[12] == '');
 {
    echo '<div>' . $row[12] . '</div><hr style="width:99%;"/><div id="gallery">';

 while($row1 = mysql_fetch_array($linijka))
        {
            $wyniki[] = $row1['images'];
        }
    foreach($wyniki as $wynik);
    $images = explode(" ", $wynik);
    foreach($images as $image)
        {
            echo '<a href="' . $image . '" rel="gallery" ><img src="' . $image . '"height="100px" /></a> ';
        }
        }
 echo '</div><hr style="width:99%;"/>';
}
?>

Thanks for answers :)

4

4 回答 4

2

改变

if(!$row[12] == '');

进入

if(!$row[12] == '')

或者

if($row[12] != '')

除此之外......它可能是“系统名”,而不是“系统名”......

于 2013-08-12T19:32:39.617 回答
0

使用双引号而不是单引号!并删除否认。

if($row[12] != "")
{
   ....

或者你仍然可以这样做:

if(!empty($row[12]))
{
   ....
于 2013-08-12T19:32:59.573 回答
0

您的语法中有多个错误。从您的 MySQL 查询开始,您的脚本应如下所示:

$result = mysql_query("SELECT * FROM mods WHERE systemname='".$nazwa."'");
while ($row = mysql_fetch_row($result))
{
    if($row[12] != '')
    {
        echo "<div>";
        echo $row[12];
        echo "</div><hr style='width:99%;'/><div id='gallery'>";
        $wyniki = array();
        while($row1 = mysql_fetch_array($linijka))
        {
            $wyniki[] = $row1['images'];
        }

        foreach($wyniki as $wynik)
        {
            $images = explode(" ", $wynik);
            foreach($images as $image)
            {
                echo "<a href='$image' rel='gallery'><img src='$image' height='100px' /></a>";
            }
        }
        echo "</div><hr style='width:99%;'/>";
    }
}
于 2013-08-12T19:36:03.143 回答
-2

你的 $result 是空的:你需要这样做:

mysql_query("SELECT * FROM mods WHERE sytemname='".$nazwa."'");
于 2013-08-12T19:32:52.180 回答