PHP图库问题

时间:2011-08-02 20:56:10

标签: php mysql

好的,我有一个由数据库填充的图库但由于某种原因它不会从2011年5月31日之后提取条目。我已经搜索了代码并且找不到任何日期限制所以我很茫然至于为什么它没有引入任何最近的条目。

我还查看了数据库表,看不到May31st之前和更多当前条目之间存在任何异常。

<?php
//GALLERY PAGE
$user="USER";
$password = "PASSWORD";
$database = "GALLERY";
$hostname_portfolio ="localhost:3306";

//gets the page number from the URL

if($_GET["pageNum"]==''){
$listedNum=0;

//gets the page limit from the URL
$limit=5;
}

else{
$listedNum=$_GET["pageNum"];

//gets the page limit from the URL
$limit=$_GET["limit"];

}
//creates the list of projects and puts them into an array
$project= array();

$con = mysql_connect($hostname_portfolio,$user,$password);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$dbcon = mysql_select_db("GALLERY", $con);
if (!$dbcon)
  {
  die('Could not connect: ' . mysql_error());
  }
  if ($dbcon)
  {
  }

 mysql_select_db($database, $con);

$result = mysql_query("SELECT * FROM Persons ORDER BY date_uploaded DESC");


  echo"<div class='clear' style='clear:both;'></div>";

$j=0;
do{
  if($row['approved']=="true"){
    $project[$j] = 
        "<div class='project-list'>
            <div class='user-project'>
                <div class='container'>
                    <div class='before-box' >
                        <p class='picture_state'>Before</p>
                        <a href='http://THEURL.com/". $row['image_path']."'>
                        <img src= '". $row['image_path']. "' width='400px' height='300px'/></a>
                        <br />
                    </div>
                    <div class='after-box'>
                        <p class='picture_state'>After</p>
                        <a href='". $row['picture_state']."'>
                        <img src= '". $row['picture_state']. "' width='400px' height='300px' /></a>
                        <br />
                    </div>
                    <div class='sidebox'>
                        <div class='inner-sidebox'>
                            <p class='date-project'>
                                Submitted by " . $row['FirstName'] . " " . $row['LastName']. " on " .$row['date_uploaded']. "</p>
                            <p> " .$row['decription']. "</p>";
            if($row['ATTR1'] || $row['ATTR2']){ 
                $project[$j] .= "<p>Used "; 
                if ($row['ATTR1']){ 
                    $project[$j] .= "PRODUCT2&trade;"; 
                    if ($row['color1']){ 
                        $project[$j] .= " in " . $row['color1']; 
                    }
                    if ($row['ATTR2']){
                        $project[$j] .= " and ";  
                    }   
                }
                if($row['ATTR2']){ 
                    $project[$j] .= "PRODUCT<sup>&reg;</sup>"; 
                    if ($row['color2']){ 
                        $project[$j] .= " in " . $row['color2']; 
                    }
                }
                $project[$j] .= "</p>"; 
            }
            $project[$j] .= "
                        </div>
                    </div>
                </div>
                <div class='clear' style='clear:both;'>
                </div>
            </div>
            <div class='clear' style='clear:both;'>
            </div>
        </div>
        <div class='clear' style='clear:both;'>
        </div>";
        $j++; 
}

}

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

$max=sizeof($project);

for($i=$listedNum;$i<$limit;$i++){

echo $project[$i];

}


$max=sizeof($project) - 1;

echo "<div class='bottom' style='width:170px;margin:0px auto;'>";

if($listedNum > 0){
    $prevPageNum=$listedNum - 5;
    $lastPage= $limit - 5;
    echo "<a href='http://THEURL.com/gallery.php?    pageNum=".$prevPageNum."&limit=".$lastPage."'>< Last Page </a>";   
}
else{
$prevPageNum=$listedNum;
$lastPage= $limit;
}
echo"&nbsp;&nbsp;";
if($limit <= $max){

$newPageNum=$listedNum + 5;
$nextPage= $limit + 5;
echo "<a href='http://THEURL.com/gallery.php?pageNum=".$newPageNum."&limit=".$nextPage."'> Next Page ></a>";    

}

else{
    $newPageNum=$listedNum;
    $nextPage= $limit;
}

echo "</div>";

mysql_close($con);
?> 

4 个答案:

答案 0 :(得分:1)

我猜它是以下之一:

  1. 您的服务器只允许您在每个查询中拉出“x”行(并且'x'不是在第31天')

  2. 或者在5月31日之后与文件有所不同。与之前的相比

答案 1 :(得分:0)

代码中没有任何内容。它可能是您的数据库配置的方式,它只允许返回一定数量的结果,并且恰好与日期一致。

答案 2 :(得分:0)

检查表格中的数据。可能是,在5月31日之后它没有被“批准”(“已批准”字段未被设置为强制转换为布尔值的东西)

答案 3 :(得分:0)

从您的代码判断 - 在5月31日之后的记录中,date_uploaded为null,或者您的数据库中出现其他错误。例如,批准在违规记录上不等于。

如果做不到这一点,也许它与这个限制有关。尝试传入高于5的数字,看看是否有更多的记录显示。

//gets the page number from the URL

if($_GET["pageNum"]==''){
$listedNum=0;

//gets the page limit from the URL
$limit=5;
}

else{
$listedNum=$_GET["pageNum"];

//gets the page limit from the URL
$limit=$_GET["limit"];

}
相关问题