当前位置: 动力学知识库 > 问答 > 编程问答 >

mysql - PHP Gallery Problem

问题描述:

Ok, I have a gallery that's being populated by a database but for some reason it's not pulling entries from beyond May 31st 2011. I've scoured the code and can't find any date limitations so I'm at a loss as to why it's not pulling in any recent entries.

I've also looked through the database table and don't see any irregularities between pre May31st and more current entries.

<?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);

?>

网友答案:

There's nothing in the code. It might be the way your database is configured where it only lets a certain number of results be returned and that happens to coincide with the date.

网友答案:

Im going to guess that its one of the following:

  1. Youre server is only allowing you to pull 'x' amount of rows within each query (and that 'x' is dont at may 31st')

  2. or theres something different with the files after may 31st. compared to the ones earlier

网友答案:

Check data in table. May be, after may 31st it was not "approved" ("approved" field was not set to something that casts to boolean TRUE)

网友答案:

Judging from your code - either date_uploaded is null in the records after May 31 or something else is wrong in your DB. Approved not equaling true on the offending records, for example.

Failing that, maybe it has something to do with this limitation. Try passing in a number higher than 5 and see if you get more records showing.

//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"];

}
分享给朋友:
您可能感兴趣的文章:
随机阅读: