如何不从我的数据库显示表的某些部分? [英] How do I not display certain parts of the table from my database?

查看:122
本文介绍了如何不从我的数据库显示表的某些部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://i.stack.imgur.com/5OTgG.png

上图描述了我的问题,并提供了一个视觉效果。
正如你所看到的,我只想保留或删除右上角的两个空格。

The image above describes my problem, and provides a visual. As you can see, I just want to reserve or delete the two spaces on the top-right. How can I achieve this?

这是我目前的代码:

<html>
<head>
</head>
<body>
    <?php
        $objConnect = mysql_connect("localhost","root","") or die(mysql_error());
        $objDB = mysql_select_db("dbname");
        $strSQL = "SELECT * FROM album";
        if (!isset($_GET['Page']))  $_GET['Page']='0';
        $objQuery = mysql_query($strSQL);
        $Num_Rows = mysql_num_rows($objQuery);

        $Per_Page = 12;   // Per Page
        $Page = $_GET["Page"];
        if(!$_GET["Page"])
        {
            $Page=1;
        }

        $Prev_Page = $Page-1;
        $Next_Page = $Page+1;

        $Page_Start = (($Per_Page*$Page)-$Per_Page);
        if($Num_Rows<=$Per_Page)
        {
            $Num_Pages =1;
        }
        else if(($Num_Rows % $Per_Page)==0)
        {
            $Num_Pages =($Num_Rows/$Per_Page) ;
        }
        else
        {
            $Num_Pages =($Num_Rows/$Per_Page)+1;
            $Num_Pages = (int)$Num_Pages;
        }

        $strSQL .=" order  by albumID ASC LIMIT $Page_Start , $Per_Page";
        $objQuery  = mysql_query($strSQL);


        echo"<table border=\"0\"  cellspacing=\"1\" cellpadding=\"1\"><tr>";
        $intRows = 0;
        while($objResult = mysql_fetch_array($objQuery))
        {
            echo "<td>"; 
            $intRows++;
    ?>
            <center>
                <img src="https://s3.amazonaws.com/thumbnails/<?=$objResult["Picture"];?>" height="190" width="190" /></a><br>
                <?=$objResult["albumName"];?>
                <br>
            </center>
    <?php
            echo"</td>";
            if(($intRows)%4==0)
            {
                echo"</tr>";
            }
        }
        echo"</tr></table>";
    ?>

        <br>
        <?php
        //DELETED PAGINATION CODE for the sake of simplicity in StackOverflow
                ?>
</body>
</html>
<?php
mysql_close($objConnect);
?>

感谢一堆!

推荐答案

您的$ intRows变量似乎是计数单元格,而不是行。所以你可以通过他们的数字,它应该是2和3简单地识别右上角的单元格。添加到你的循环:

Your $intRows variable seems to be counting cells, not rows. So you can simply identify the top right cells by their numbers, which should be 2 and 3. Add this to your loop:

$cell = 0;
echo '<table border="1" cellpadding="2" cellspacing="1"><tr>';
while($objResult = mysql_fetch_array($objQuery))
{
  if($cell % 4 == 0) {
    echo '</tr><tr>';
  }

  if($cell == 2 || $cell == 3) {
    echo '<td>RESERVED</td>';
  } else {
    echo '<td>'.$objResult["albumName"].'</td>';
  }

  $cell++;
}
echo '</tr></table>';

这篇关于如何不从我的数据库显示表的某些部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆