maybe it would help if I'll post the code for
page_it()
function page_it($tablename, $fields, $perpage)
{
$fields = unserialize($fields);
global $p;
if (!isset($p)) $p = 1;
$q = db_query("SELECT ID FROM $tablename");
$r = mysql_fetch_array($q) or die (mysql_error());
$totalpages = count($r) / $perpage;
if ((integer)$totalpages > $totalpages) {
settype($totalpages, integer);
$totalpages++;
}
mysql_free_result($q);
$current = ($p-1) * $perpage;
$totalfields = count($fields);
$field_string = $fields[0];
if($totalfields > 1) {
for($x=1;$x<=$totalfields-1;$x++) {
$field_string .= ",";
$field_string .= $fields[$x];
}
}
$q = db_query("SELECT $field_string FROM $tablename LIMIT $current, $perpage");
return array ($q, $totalfields);
}
and I used it like this:
$fields = array(0 => 'title', 1 => 'text', 2 => 'date', 3 => 'UID');
$fields = serialize($fields);
list($q,$totalfields) = page_it("news",$fields,7);
and then the while I typed above, any suggestions?
Arik