![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
请各位大侠帮助,,
为什么我没加
查询失败!");
$colcount=ocinumcols($result_jldw);//得到的总列数
require('../common/pager_functions.php');//分页函数调用
$current_rows = OCIFetchstatement($result_jldw,$result_jldw1
if ($current_rows>0){
for ($i=0;$i<$current_rows;$i++){//此for循环为,输出数据
echo "\n";
echo" \n";
}
}
ocifreestatement($result_jldw);
?>
可能是分页代码的原因吧,但我找不出来,
分页的代码如下:
<?php
function draw_pager($id,$url, $total_pages, $current_page = 1) {
if ( $current_page <= 0 || $current_page > $total_pages ) {
$current_page = 1;
}
if ( $current_page > 1 ) {
printf( "[首页] \n" , 1);
printf( "[上一页] \n" , ($current_page-1));
}
echo "第[ ";
for( $i = ($current_page-5); $i <= $current_page+5; $i++ ) {
if ($i < 1) continue;
if ( $i > $total_pages ) break;
if ( $i != $current_page ) {
printf( "%1\$d \n" , $i);
} else {
printf("%1\$d \n",$i);
}
}
echo "]页 ";
if ( $current_page < $total_pages ) {
printf( "[下一页] \n" , ($current_page+1));
printf( "[末页] \n" , $total_pages);
}
}
function total_pages($total_rows, $rows_per_page) {
if ( $total_rows < 1 ) $total_rows = 1;
return ceil($total_rows/$rows_per_page);
}
function page_to_row($current_page, $rows_per_page) {
$start_row = ($current_page-1) * $rows_per_page + 1;
return $start_row;
}
function count_rows(& $conn, $select) {
$sql = "SELECT COUNT(*) AS num_rows FROM($select)";
$stmt = ociparse($conn,$sql);
ocidefinebyname($stmt,"NUM_ROWS",$num_rows);
ociexecute($stmt);
ocifetch($stmt);
return $num_rows;
}
function & paged_result(& $conn, $select, $start_row, $rows_per_page) {
$sql = "SELECT * FROM
(SELECT r.*, ROWNUM as row_number FROM
( $select ) r WHERE ROWNUM <= :end_row)
WHERE :start_row <= row_number";
$stmt = ociparse($conn,$sql);
ocibindbyname($stmt, ':start_row', $start_row);
// Calculate the number of the last row in the page
$end_row = $start_row + $rows_per_page - 1;
ocibindbyname($stmt, ':end_row', $end_row);
ociexecute($stmt);
// Prefetch the number of rows per page
ocisetprefetch($stmt, $rows_per_page);
return $stmt;
}
?>
<?
//function & query_result($c_sql,$c_result,$rows_per_page) {
//echo $c_sql;
$rows_per_page = 13;
$url = '';
$total_rows = count_rows($DBCONN,$sql_jldw);
$total_pages = total_pages($total_rows, $rows_per_page);
// Make sure the page number is a sane value
if ( !isset($_GET['page']) ||
!preg_match('/^[0-9]+$/',$_GET['page']) ||
$_GET['page'] < 1 ) {
$_GET['page'] = 1;
} else if ( $_GET['page'] > $total_pages ) {
$_GET['page'] = $total_pages;
}
// Translate the page number into a starting row number
$start_row = page_to_row($_GET['page'], $rows_per_page);
// Filter to a single page of rows
$result_jldw = & paged_result($DBCONN, $sql_jldw, $start_row, $rows_per_page);
//}
?>
[ 本帖最后由 chuhongbin 于 2007-7-13 09:27 AM 编辑 ]";
echo $result_jldw1[$i];
foreach ($result_jldw1 as $data) {
echo " $data[$i] $result_jldw1[$i]\n";
}
echo "

