Salut!
is there a good way to present data from table (many fields / not only one)
into $itemData instead of array_push (line 12 .. 16) ?
And how come the result always has space (kinda <TR><TD>) and it's moving
upper and upper when I click Next.
Correction to my code below would be very welcome .
1 <?php
2 /**
3 * PEAR DB
4 */
5 require_once "DB.php";
6
7 $db = DB::connect("mysql://valerie:@localhost/valerie");
8 $q = 'SELECT * FROM country LIMIT 0,30';
9 $res = $db->query($q);
10 $total = $res->numRows();
11
12 $from_db = array();
13 while ( list($id, $country) = $res->fetchRow() ) {
14 $special_from_db = array();
15 array_push($special_from_db, $id, $country);
16 array_push($from_db, $special_from_db);
17 }
18
19 /**
20 * PEAR Pager
21 */
22 require_once 'Pager/Pager.php';
23
24 $params = array(
25 'mode' => 'Jumping',
26 'perPage' => 10,
27 'delta' => 3,
28 'itemData' => $from_db
29 );
30 $pager = & Pager::factory($params);
31 $data = $pager->getPageData();
32 $links = $pager->getLinks();
33
34 echo $links['all'];
35 echo $pager->linkTags;
36 ?>
37 <table border="1">
38 <tr>
39 <th>ID</th>
40 <th>Country</th>
41 </tr>
42 <?
43 for ( $i=0; $i<sizeof($from_db); $i++ ) {
44 echo "<tr>";
45 for ( $j=0; $j<sizeof($data[$i]); $j++ ) {
46 echo "<td>". $data[$i][$j] ."</td>";
47 }
48 echo "</tr>";
49 }
50 ?>
51 </table>
Thank you.
Val�rie Delon
�tudiante
// on a besoin d'apprendre beacoup plus
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php