I'm creating a module for a Scuba logbook.

On the screen i want to put a pager with << first < prev next> last>>

How can i do that?

Comments

krishnarp’s picture

Here is a simple pager query usage

$sql ='SELECT * FROM {zc_componenttype} ';
$result = pager_query($sql, 10, 0, NULL);
$rows = array();

while ($componenttypeRow = db_fetch_object($result)) {
$rows[] = array($componenttypeRow->typeid,
$componenttypeRow->type,
$componenttypeRow->comtypelabel,
$componenttypeRow->zctablename,
l(t('Edit'), 'component/componenttype/edit/'.
$componenttypeRow->typeid),
l(t('Cancel'), 'component/componenttype/cancel/'.
$componenttypeRow->typeid));
}
$header = array(t('Type Id'), t('Type'),t('Label'), t(' Tablename'), array('data' => t('Operations'),
'colspan' => 2));
if(!$rows) {
$rows[] = array(array('data' => t('No requests available.'), 'colspan' => 5));

}
$output=theme('table', $header, $rows);
$output.=theme('pager', NULL, 10, 0);
return $output;

Hope this help u.

maarten61085’s picture

it works perfect.

I spend hours on programming a table with td and tr in html. Sql etc.

And with this it works in a few minutes.

Is it possible to start with the last page. Because this contains the last dive, and that is the most interesting?

krishnarp’s picture

You want to see result from the last page??
Set order by descending in query for some field that you want to sort.

sujith7c’s picture

Friend

That works but only showing 10 rows in a page ,No back ,Previous,Next link i have lot of rows in the query

krishnarp’s picture

Sujith,

Check whether your query keywords capitalised or show me your query ?

sujith7c’s picture

$sqlquery="SELECT profile.nid,profile.field_name_value,profile.field_age_value,profile.field_sex_value,profile.field_height_value,t1.name AS caste,t2.name AS religion,t3.name AS location,files.filepath as imgloc FROM content_type_profile AS profile inner join term_data AS t1 on profile.field_caste_tid=t1.tid inner join term_data AS t2 on profile.field_religion_tid=t2.tid inner join term_data AS t3 on profile.field_location_tid=t3.tid left join files on files.nid=profile.nid-1 WHERE profile.field_sex_value='".$sex."'";

$result=pager_query($sqlquery,5,0,NULL);

krishnarp’s picture

Try this

$sqlquery="SELECT profile.nid, profile.field_name_value, profile.field_age_value, profile.field_sex_value, profile.field_height_value, t1.name AS caste, t2.name AS religion, t3.name AS location, files.filepath AS imgloc FROM content_type_profile AS profile INNER JOIN term_data AS t1 ON profile.field_caste_tid=t1.tid INNER JOIN term_data AS t2 ON profile.field_religion_tid=t2.tid INNER JOIN term_data AS t3 ON profile.field_location_tid=t3.tid LEFT JOIN files ON files.nid=profile.nid-1 WHERE profile.field_sex_value='%s'";

$result=pager_query($sqlquery.$sex,5,0,NULL);
sujith7c’s picture

Hello

I have problem in showing queried results on multiple pages

$srch_rslt .=theme('pager',NULL,10,0);
return $srch_rslt;

this is my query

$result=pager_query($sqlquery,10,0,$GL_count_query);

$Countqry="select count(*) FROM content_type_profile as profile inner join term_data AS t1 on profile.field_caste_tid=t1.tid inner join term_data AS t2 on profile.field_religion_tid=t2.tid inner join term_data AS t3 on profile.field_location_tid=t3.tid left join files on (files.nid=profile.nid-1 AND files.filename='".$Imagetpe."') WHERE profile.field_sex_value='".$sex."'";

$GL_count_query=$Countqry." AND profile.field_age_value BETWEEN'".$age_lower_limit."' AND '".$age_upper_limit."'";

it is hwoing 10 records but there is no link to other result pages

help me
looking forward you