douzhaobo6488 2014-05-17 18:09
浏览 66
已采纳

php没有考虑到html

Hullo :)

I'm sorry if the title is not clear but I don't know how to ask this ( +, I'm not english native :/ )

So ! There, I'm trying to build a website with a php script that spit out a list of members. Everything works fine but the list is not taking into account by the html/css part.

The thing is working fine ( here : http://occlumens.eu/fanlist/membership.php ) but the code is ugly, all tables and it is hell to make something nice in CSS. So ! I decided to work on it and try to just make the whole a bit more interesting with divs.

Here for a visual explanation : http://occlumens.eu/fanlist/membership2.php

As you can see, the list is fine but the box ( html/css ) is not taking the list. From what I see, my div classes are closing all well but it is as if it wouldn't "read" the php.

If I make a min-height in the css, it will only make a box as big as I want, but it still won't take the php into account. So, if the list is smaller or bigger, it won't stretch.

How can I correct that ? Is it because the list is conditional ? ( if conditions ) Send help :) Also, I'm starting to understand php, only starting :) Consequently, I did not code the script.

<div class="boxy">
    <h3>Members</h3>
    <p><a href="membership.php?sort=all">Complete list</a> - <a href="membership.php?sort=country">Sorted by country</a></p>
    <p>We have a total of <strong><?php echo PHPFANLIST_MEMBERCOUNT; ?></strong> member(s) from <strong><?php echo $country_count; ?></strong> different countries.</p>

    <?php if (($sort == 'country') && is_null($country)) { // Same sort as above! ?>
    <h2>Sorted by country</h2>
    <div class="membership">

        <div class="one_half">
            <a href="membership.php?sort=country">Country</a>
            <?php foreach ($countries as $country) { ?>
                <p><a href="membership.php?country=<?php echo htmlentities($country['name'], ENT_QUOTES, 'UTF-8'); ?>" title="<?php echo $country['name']; ?>"><?php $fake_member = new Member(); $fake_member->country = $country['name']; if (!DoPluginCalls('show_members_country', true, $fake_member)) { echo htmlentities($country['name'], ENT_QUOTES, 'UTF-8'); } ?></a></p>
            <?php } ?>
        </div>

        <div class="one_half">
            <a href="membership.php?sort=country&amp;orderby=num">Members</a>
            <?php foreach ($countries as $country) { ?>
                <p><?php echo $country['members']; ?></p>
            <?php } ?>      
        </div>
    </div>

<?php } else { 
    $querystring = '';
    $showmailcol = ShowMail(true, $fanlisting->settings['show_mail']);
?><h2><?php if (!is_null($country)) { $querystring = htmlentities('&country=' . $country, ENT_QUOTES, 'UTF-8'); ?>Sorted by country: <?php echo htmlentities($country, ENT_QUOTES, 'UTF-8'); } else {?>All members<?php } ?></h2>
    <div class="membership">

    <div class="one_fifth">
        <?php if ($fanlisting->settings['show_member_id']) { ?>
            <a href="membership.php?sort=all&amp;orderby=id<?php echo $querystring; ?>">ID</a>
        <?php } ?>
        <?php foreach ($members as $member) { ?>
            <?php if ($fanlisting->settings['show_member_id']) { ?>
                <p><?php if (!DoPluginCalls('show_members_id', true, $member)) { echo $member->id; }?></p>
            <?php } ?>
        <?php } ?>
    </div>

    <div class="one_fifth">
        <a href="membership.php?sort=all&amp;orderby=name<?php echo $querystring; ?>">Name</a>
        <?php foreach ($members as $member) { ?>
            <p><?php if (!DoPluginCalls('show_members_name', true, $member)) { echo htmlentities($member->name, ENT_QUOTES, 'UTF-8'); } ?></p>
        <?php } ?>
    </div>

    <div class="one_fifth">
        <?php if ($showmailcol) { ?>
            <a href="membership.php?sort=all&amp;orderby=mail<?php echo $querystring; ?>">E-mail</a>
        <?php } ?>
        <?php foreach ($members as $member) { ?>
            <?php if ($showmailcol) { ?>
                <p><?php if (!DoPluginCalls('show_members_mail', true, $member)) { if (ShowMail($member->showmail, $fanlisting->settings['show_mail'])) { ?><a href="mailto:<?php echo scramble_email(htmlentities($member->mail, ENT_QUOTES, 'UTF-8')); ?>">@</a><?php } else { echo '-'; } } // Plugin Call ?></p>
            <?php } ?>
        <?php } ?>
    </div>

    <div class="one_fifth">
        <?php if ($fanlisting->settings['show_url']) { ?>
            <a href="membership.php?sort=all&amp;orderby=url<?php echo $querystring; ?>">URL</a>
        <?php } ?>
        <?php foreach ($members as $member) { ?>
            <?php if ($fanlisting->settings['show_url']) { ?>
                <p><?php if (!DoPluginCalls('show_members_url', true, $member)) { if (!is_empty($member->url)) { ?><a href="<?php echo htmlentities(handle_site($member->url), ENT_QUOTES, 'UTF-8'); ?>" target="_blank"<?php if ($fanlisting->settings['url_nofollow']) { echo ' rel="nofollow"'; }?>>www</a><?php } else {echo 'www'; } } // Plugin Call ?></p>
            <?php } ?>
        <?php } ?>
    </div>

    <div class="one_fifth">
        <?php if ($fanlisting->settings['ask_country'] && is_null($country)) { ?>
            <a href="membership.php?sort=all&amp;orderby=country">Country</a>
        <?php } ?>
        <?php foreach ($members as $member) { ?>
            <?php if ($fanlisting->settings['ask_country'] && is_null($country)) { ?>
                <p><?php if (!DoPluginCalls('show_members_country', true, $member)) { if (!is_empty($member->country)) { echo htmlentities($member->country, ENT_QUOTES, 'UTF-8'); } else { echo '-'; } } // Plugin Call ?></p>
            <?php } ?>
        <?php } ?>
    </div>

    <div class="one_fifth">
        <?php if ($fanlisting->settings['show_custom'] && ($fanlisting->settings['custom_field_name'] != '')) { ?>
            <a href="membership.php?sort=all&amp;orderby=custom<?php echo $querystring; ?>"><?php echo htmlentities($fanlisting->settings['custom_field_name'], ENT_QUOTES, 'UTF-8'); ?></a>
        <?php } ?>
        <?php foreach ($members as $member) { ?>
            <?php if ($fanlisting->settings['show_custom'] && ($fanlisting->settings['custom_field_name'] != '')) { ?>
                <p><?php if (!DoPluginCalls('show_members_custom', true, $member)) { if (!is_empty($member->custom)) { echo htmlentities($member->custom, ENT_QUOTES, 'UTF-8'); } else { echo '-'; } } // Plugin Call ?></p>
            <?php } ?>
        <?php } ?>
    </div>
</div>
<?php } ?>
  • 写回答

3条回答 默认 最新

  • doujiaoang69440 2014-05-17 18:23
    关注

    It's hard to tell without seeing the php code. By looking at the links though, you could start by setting the table's width to 100% (or whatever width you want). If you cannot figure out how to modify the table tag in php, you can always reference it with css using the parent div like this

    .boxy table {
         width: 100%;
         /* any other styles here */
    }
    

    As for the second example, the reason the div doesnt wrap all of the content is because the divs inside it are floating left. If you put something with the style clear:left at the end, right before the closing boxy div, this will make it wrap all the floating content as well.

    <span style="clear: left>&nbsp;</span>
    

    You are probably going to want to stick with a table though since it keeps all of the rows in line.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?