1

我对列“cena”(eng:price)的数据进行排序时遇到了一些问题。

我制作了具有多种语言的网站,我为每种语言 slike、en_slike、ger_slike(塞尔维亚语、英语、德语)制作了 3 个表格,我想在一个页面中显示它,我可以按价格(cena)和日期(slike_id)对数据进行排序),当我运行页面时,一切都很好,但是当我尝试按 cena(价格)对图片进行排序时,什么都没有发生,为什么?

这是在工作之前:

这是图片选择功能的代码,该功能在类Manage中:

public static function Select_Slike(){
        if(isset($_POST['btnsort']))
        {
            if(isset($_POST['sort']))
            {
                if($_POST['sort']=="cena")
                {   
                    $query = "(select * from slike order by cena desc) 
                        union all
                        (select * from en_slike order by cena desc)
                        union all
                        (select * from ger_slike order by cena desc)
                        ";

                    $rez = mysql_query($query);
                    while($row = mysql_fetch_array($rez))
                    {
                        echo '<div id="block1"><h5 id="naslov">'.$row['naslov'].'</h5><h5 id="cena">'.$row['cena'].'</h5><img src="images/'.$row['string'].'.jpg" class="slike"/><h5 id="materijal">'.$row['materijal'].'</h5><h5 id="dimenzije">'.$row['dimenzije'].'</h5></div>';
                    }
                }
                else
                {
                    $query =   "(select * from slike order by slike_id desc) 
                                union all
                                (select * from en_slike order by slike_id desc)
                                union all
                                (select * from ger_slike order by slike_id desc)
                                ";

                    $rez = mysql_query($query);
                    while($row = mysql_fetch_array($rez))
                    {
                        echo '<div id="block1"><h5 id="naslov">'.$row['naslov'].'</h5><h5 id="cena">'.$row['cena'].'</h5><img src="images/'.$row['string'].'.jpg" class="slike"/><h5 id="materijal">'.$row['materijal'].'</h5><h5 id="dimenzije">'.$row['dimenzije'].'</h5></div>';
                    }
                }
            }   
        }
        else
        {
            $query =   "(select * from slike order by slike_id desc) 
                        union all
                        (select * from en_slike order by slike_id desc)
                        union all
                        (select * from ger_slike order by slike_id desc)
                        ";

            $rez = mysql_query($query);

            while ($row = mysql_fetch_array($rez)) 
            { 
                echo '<div id="block1"><h5 id="naslov">'.$row['naslov'].'</h5><h5 id="cena">'.$row['cena'].'</h5><img src="images/'.$row['string'].'.jpg" class="slike"/><h5 id="materijal">'.$row['materijal'].'</h5><h5 id="dimenzije">'.$row['dimenzije'].'</h5></div>';
            }
        }   
    }

这是正文 php/html 代码:

<body>
    <form action="" method="post">
    <div id="sortiranje">
        <select name="sort">
            <option value="date">Datum</option>
            <option value="cena">Cena</option>
        </select><input type="submit" name="btnsort" value="sort"/>
    </div>
    </form>
    <div id="slike_blok">
    <?php
    try{
    Manage::Select_Slike();
    }
    catch(Exception $e){
        die("<center><font size='42' color='red' weight='100'>SERVER DATABASE ERROR! ".$e->Message()."</font><center>");
    }
    ?>
    </div>
</body>
4

1 回答 1

1

尝试这样的顺序应该是所有工会的结束

public static function Select_Slike(){
   if(isset($_POST['btnsort']))
   {
       if(isset($_POST['sort']))
       {
          if($_POST['sort']=="cena")
           {   
              $query = "(select * from slike) 
              union all
              (select * from en_slike)
              union all
             (select * from ger_slike) order by cena desc";

$rez = mysql_query($query);
while($row = mysql_fetch_array($rez))
{
echo '<div id="block1"><h5 id="naslov">'.$row['naslov'].'</h5><h5 id="cena">'.$row['cena'].'</h5><img src="images/'.$row['string'].'.jpg" class="slike"/><h5 id="materijal">'.$row['materijal'].'</h5><h5 id="dimenzije">'.$row['dimenzije'].'</h5></div>';
}
}
else
{
$query =   "(select * from slike) 
union all
(select * from en_slike)
union all
(select * from ger_slike) order by slike_id desc
";

$rez = mysql_query($query);
while($row = mysql_fetch_array($rez))
{
echo '<div id="block1"><h5 id="naslov">'.$row['naslov'].'</h5><h5 id="cena">'.$row['cena'].'</h5><img src="images/'.$row['string'].'.jpg" class="slike"/><h5 id="materijal">'.$row['materijal'].'</h5><h5 id="dimenzije">'.$row['dimenzije'].'</h5></div>';
}
}
}   
}
else
{
$query =   "(select * from slike) 
union all
(select * from en_slike)
union all
(select * from ger_slike) order by slike_id desc
";

$rez = mysql_query($query);

while ($row = mysql_fetch_array($rez)) 
{ 
echo '<div id="block1"><h5 id="naslov">'.$row['naslov'].'</h5><h5 id="cena">'.$row['cena'].'</h5><img src="images/'.$row['string'].'.jpg" class="slike"/><h5 id="materijal">'.$row['materijal'].'</h5><h5 id="dimenzije">'.$row['dimenzije'].'</h5></div>';
}
}   
}
于 2013-05-10T15:00:20.987 回答