note 140 added to gtk.gtkclist.method.append.php
| From: | tome_kaa at yahoo dot fr | Date: | Tue, 14 May 2002 15:04:52 +0000 |
| Subject: | note 140 added to gtk.gtkclist.method.append.php | ||
| Groups: | php.gtk.webmaster | ||
| Request: | Send a blank email to php-gtk-webmaster+get-456@lists.php.net to get a copy of this message | ||
Usefull for databases !
Here's a PostgreSQL example :
(should work on all databases if you respect the small differencies between them)
<?php
if (!class_exists('gtk')) {
dl('php_gtk.so');
dl('pgsql.so');
}
function shutup()
{
gtk::main_quit();
}
$connect=pg_connect("user=xxx dbname=xxx");
$result=pg_exec("select name,firstname from namelist");
$window = &new GtkWindow();
$scroll= &new GtkScrolledWindow();
$clist = &new GtkCList(2,array("Name","Last Name"));
for($i=0;$i<$numrows=pg_numrows($result);++$i)
{
$row[$i]=pg_fetch_row($result,$i);
}
/*The row array is filled so that we can use the foreach style, which is usefull here*/
foreach ($row as $app) $clist->append($app);
/* $app[0] = $row[$i][0]
$app[1] = $row[$i][1]
That's what append wants */
/*Just for the output */
$clist->set_column_min_width(0, 100);
$clist->set_column_min_width(1, 100);
$clist->columns_autosize();
$scroll->add($clist);
$window->set_default_size(400,800);
$window->add($scroll);
$window->connect("destroy","shutup");
$window->show_all();
gtk::main();
?>
http://gtk.php.net/manual/en/gtk.gtkclist.method.append.php