Php Switch声明没有显示重定向和链接的所有案例

时间:2016-09-18 19:53:07

标签: php switch-statement

我是PHP的初学者。请帮我解决我的代码错误: 这是代码

<?php
     $qry=" SELECT * FROM `allopathy_cosmetology`
           UNION 
            SELECT * FROM `ayurveda_allergy`
           UNION 
            SELECT * FROM `beauty`
           UNION 
            SELECT * FROM `sidha_ophtalmology`
           UNION 
            SELECT * FROM `traditional`
           ORDER BY `Created_Date` DESC ";
     $sql=db_query($qry);
     while($obj=db_fetch_object($sql)){
        switch ($obj->video_img . $obj->v_id) {

        case 1:
            $obj->link="page/allopathy/cometology.php?v_id=".$obj->v_id;
            $obj->img="video/allopathy/thumb/".$obj->video_img;
            break;
        case 2:
            $obj->link="page/allopathy/cometology.php?v_id=".$obj->v_id;
            $obj->img="video/ayurveda/thumb/".$obj->video_img;
            break;
        case 3:
            $obj->link="page/traditional/index.php?v_id=".$obj->v_id;
            $obj->img="video/beauty/thumb/".$obj->video_img;
            break;
        case 4:
            $obj->link="page/sidha/ophtalmology.php?v_id=".$obj->v_id;
            $obj->img="video/sidha/thumb/".$obj->video_img;
            break;
        case 5:
            $obj->link="page/traditional/index.php?v_id=".$obj->v_id;
            $obj->img="video/traditional/thumb/".$obj->video_img;
            break;
        default :
            $obj->link="#";
            $obj->img="#";
        }
        echo " 

        <li><a href='$obj->link'>
        <img width='100px' src='$obj->img' /> <br />
        $obj->subject<br />$obj->author</a><hr /></li>";
    }
    ?>

问题是,它没有正确重定向,而且图像也没有正确显示。只有最后一种情况(CASE 5)才能正常运行。从1到4的其他情况都不会打印图像和链接。

0 个答案:

没有答案