Paging with multiple rows and column

If you want to do paging in php with multiple rows and columns you can use this code…

<?php

$i = 1;
$numcols = 6;                                                             // total number of  columns you want to display
$numcolsprinted = 0;                                             // no of columns so far
$numitems = count($city_arr);                        // Number of Items
$numrows = ceil($numitems/$numcols);   // Number of Rows

echo ‘‘;
for ($row=1; $row <= $numrows; $row++)
{
$cell = 0;
echo ‘‘.”n”;

for ($col=1; $col <= $numcols; $col++)
{
echo ‘‘.”n”;
}

echo ‘‘.”n”;
}
echo ‘‘.”n”;
if ($col===1)
{
$cell += $row;
if($city_arr[$cell – 1] == ”)
{

}
else
{
if(is_array($city_arr2))
{
$sel2 = ”;
if(in_array($city_arr[$cell – 1], $city_arr2))
{
$sel2 = “checked=’checked’”;
}
}
echo ‘‘;
echo “ ”;
}
print $city_arr[$cell – 1];
echo ‘‘;
}
else
{
$cell += $numrows;
echo ‘‘;
if($city_arr[$cell – 1] == ”)
{

}
else
{
if(is_array($city_arr2))
{
$sel2 = ”;
if(in_array($city_arr[$cell – 1], $city_arr2))
{
$sel2 = “checked=’checked’”;
}
}
echo “ ”;
}
print $city_arr[$cell – 1];
echo ‘‘;

}

echo ‘‘;
?>

Posted in PHP | Tagged , , , | Comments Off

Comments are closed.