与div定位的概率

时间:2012-07-20 23:44:02

标签: php html css

这是我的代码

while($row=  mysql_fetch_array($result)) {

                $type = $row[0];
                $user_from = $row[1];
                $operation_to = $row[2];
                $time = $row[3];

                if($type=="vote") {
                    echo self::vote_activity($user_from,$operation_to);

                }
                else if($type=="upload_album") {
//                    echo self::upload_activity($user_from,$operation_to);
                }
                else if($type="create_account") {

                }
                else {

                }
        }

功能投票活动是

function vote_activity($user_from,$operation_to) {
        ob_start();
        global $db;
        $table = "userinformation";
        $data = array("user_id"=>$user_from);
        $result = $db->select($table,$data);
        while($row = mysql_fetch_array($result)) {
            $name = $row[1]." ".$row[2];
        }

        $table = "photo_gallery";
        $data = array("photo_id"=>$operation_to);
        $result = $db->select($table,$data);
        while($row = mysql_fetch_array($result)) {
            $extension = $row[6];
            $user_id = $row[0];
        }

        $source_file_path = basedir."/storage/".$user_id."/".$operation_to.".".$extension;
        $height=200;
        $width=200;
        ?>

            <div class="vote_activity_div" >
                <p class="vote_p"><a><?php echo $name?></a> vote this photo.</p>
                <img class="vote_image" src="Create_thumbnail.php?source_file_path=<?php echo $source_file_path;?>&extension=<?php echo $extension; ?>&height=<?php echo $height; ?>&width=<?php echo $width; ?>"/>
            </div>   
        <?php
        $vote_activity = ob_get_contents();
        ob_clean();
        return $vote_activity;
    }

问题在于,当我第一次投票div离开父div时,我多次调用这个vote_activity类。

1 个答案:

答案 0 :(得分:0)

我认为您最好的选择是确保代码输出到已清除浮动的父DIV等,以确保没有转义。因此,在运行脚本之前,或者您正在执行此操作之前,请使用类vote_activity_parent

创建父div

我希望这有帮助!

我认为可能值得补充的是,您可能还需要检查您的代码以确保它在正确的位置输出,否则您的脚本可能会将此DIV输出到任何真正不适合控制的地方。