0

我正在尝试制作一个包含电影的网站,一切都很好,但我只有一个小问题,每当我制作网站时,我都会在本地计算机上完成所有工作测试然后我上传网络,下面的代码用于带有查询的分页,它在 WAMP(本地)中运行良好。但是当我将分页代码上传到我的网络服务器时,它显示不存在。它显示了其他部分,有什么问题?

<?php

$per_page = 35; 
 $page = 1;
 if (isset($_GET['page'])) 
 {
  $page = intval($_GET['page']); 
  if($page < 1) $page = 1;
}

 $start_from = ($page - 1) * $per_page; 

$con= mysql_connect("localhost","sarya_asad","Thisisfor123");
 mysql_select_db('saryaal_com_movies',$con);

 $current_items = mysql_query( "SELECT * FROM `english` LIMIT $start_from, $per_page");
 if( mysql_num_rows($current_items) > 0)
 {
  while($item = mysql_fetch_assoc($current_items))
  {

  ?>
    <tr>
        <td> <strong><a href="english/english-preview.php?id=<?php echo$item['id']?>" ><?php echo $item['title'] ;?></a>    </strong></td>
        <td> <strong> <?php echo $item['year'] ;?>  </strong></td>
        <td> <strong> <?php echo $item['quality'] ;?>   </strong> </td>
    </tr>
    <tr><td>
    <?php
    }
 }
 else
 {
  echo 'this page does not exists'; 
 }

 $total_rows = mysql_query("SELECT COUNT(*) FROM `english`");
 $total_rows = mysql_fetch_row($total_rows);
 $total_rows = $total_rows[0];

 $total_pages = $total_rows / $per_page;
 $total_pages = ceil($total_pages); # 19/5 = 3.8 ~=~ 4

 for($i = 1; $i  <= $total_pages; ++$i)
 {
  echo "<a href='temp2.php?page=$i' class='pagNumActive'>$i</a> &nbsp;&nbsp;";
 }
 ?>
4

5 回答 5

1
<?php if($Strkeyword=="" AND $StrLoc=="" AND $StrMinsal=="-1" AND $StrMaxsal=="-1" AND $StrMax_exp=="maximum" AND $Strcategory=="" AND $Strjobtype=="") {
 $sql=mysql_query("select * from job where AND status='Active'");
 } 
$per_page = 5;
 $page = 1; 
if (isset($_GET['page'])) { 
$page = intval($_GET['page']);
 if($page < 1) $page = 1; 
} 
$start_from = ($page - 1) * $per_page;
 if($Strkeyword=="" AND $StrLoc=="" AND $StrMinsal=="-1" AND $StrMaxsal=="-1" AND $StrMax_exp=="maximum" AND $Strcategory=="" AND $Strjobtype=="") 
{ 
$current_items=mysql_query("select * from job LIMIT $start_from, $per_page"); } $start_from, $per_page");
 if( mysql_num_rows($current_items)>0) { while($arr=mysql_fetch_array($current_items)) {
?> 

<?php include("include/result.php") ?>// result u want to display 
<?php 
} 
} else { 
echo 'Data does not exists'; } 
if($Strkeyword=="" AND $StrLoc=="" AND $StrMinsal=="-1" AND $StrMaxsal=="-1" AND $StrMax_exp=="maximum" AND $Strcategory=="" AND $Strjobtype=="") {
 $total_rows=mysql_query("select COUNT(*) from job where AND status='Active'");
 } 
$total_rows = mysql_query("SELECT COUNT(*) FROM job");
 $total_rows = mysql_fetch_row($total_rows); 
$total_rows = $total_rows[0]; 
$total_pages = $total_rows / $per_page;
 $total_pages = ceil($total_pages);
 # 19/5 = 3.8 ~=~ 4 
echo "<div style='margin-left:280px;'>";
 echo "Page : ";
 for($i = 1; $i <= $total_pages; $i++) {
 echo "[<a style='text-decoration:none' href='search_result.php?page=$i' class='pagNumActive'>$i</a>&nbsp;]"; 
} 
echo "</div>"; 
?> 
于 2013-12-26T07:54:52.490 回答
0

你可能想使用类似的东西:

$per_page = 35;
$start_from = $page * $per_page - $per_page;
于 2013-01-16T21:49:58.717 回答
0

这是你的问题:

$con= mysql_connect("localhost","sarya_asad","Thisisfor123");
    mysql_select_db('saryaal_com_movies',$con);

您需要更改主机详细信息。localhost是您机器上的本地服务器。

于 2013-01-16T21:51:29.880 回答
0

改变这个

 $start_from = ($page - 1) * $per_page;

 $start_from = ($page) * $per_page;
于 2013-01-16T21:48:33.257 回答
0

试试这个分页逻辑:

您的目标是抵消您希望在每页上显示的图像数量。

因此,假设您想在一个页面上显示 6 个电影缩略图……您将拥有:

$videos_per_page = 6
$pageNumber = (isset($_GET['page']) ? ($_GET['page']) : 1);

你的偏移量将是:

$offset = $videos_per_page * $pageNumber 

(6 个视频 * 第 0 页...所以您抵消了 0 个视频。这很好,因为您想在第 0 页的数据结构中显示前 6 个视频)。


所以现在您有了偏移值...您需要将数组指针设置到正确的位置...循环遍历存储电影的数据库行并将指针移动您的偏移值...将其存储在 $videos_to_offset 中。 ..

while ($videos_per_page < $offset && ($row = $Query_Result->fetch_assoc())) {
    $videos_to_offset++;
}

现在你可以遍历你的数据库行,从你的偏移数组指针离开的地方输出你的视频:

    $video_counter = 0;
    while ($video_counter < $videos_per_page && ($row = $Query_Result->fetch_assoc())) {

        echo   $row['videopath'];
        $video_counter++;
}

类似的东西。

于 2013-01-16T22:23:15.467 回答