Re: Select box equiv

From: Date: Wed, 02 Apr 2003 10:28:47 +0000
Subject: Re: Select box equiv
References: 1 2  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-3201@lists.php.net to get a copy of this message
----- Original Message ----- From: "Chris Hayes" <chayes@antenna.nl> To: <php-gtk-general@lists.php.net> Sent: Wednesday, April 02, 2003 11:19 AM Subject: Re: [PHP-GTK] Select box equiv > At 10:05 2-4-03, you wrote: > > > 1. Is GtkCombo meant to be the equivalent of an HTML select box? If so, > > > are there any examples of setting up similar behavior; i.e., the user > > > selects an item from the list, and the remaining form fields are > >populated, > > > based on related Mysql calls? The manual only shows how to change the > >list > > > itself. > > > > > > >You can change the values of gtkcombo with for() or while() and you can fill > >up the list with any value, mysql data or something. > > > I would love to see a simple but complete example of that. Being used to > web-PHP the interactivity is something i still have to get used to. > > Example: <?php dl("php_gtk." . (strstr(PHP_OS, "WIN") ? "dll" : "so")); $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object("destroy", array("gtk", "main_quit")); $combo = &new GtkCombo(); $list = $combo->list; $entry = $combo->entry; $z = array(); $c = mysql_connect("host","user","pass"); mysql_select_db("alaplaya", $c); $sql = "select * from table"; $q = mysql_query($sql, $c); while($row= mysql_fetch_array($q)) { $z[] = $row["something"]; } print_r($z); for($i=0;$i < count($z);$i++) { $item = &new GtkListItem(); $box = &new GtkHBox(); $label = &new GtkLabel(($z[$i])); $box->pack_start($label, false, false, 10); $item->add($box); $combo->set_item_string($item, ""); $data = $z[$i]; //echo $data."\n"; $item->set_data($data, $data); $list->add($item); $item->show_all(); } $window->add($combo); $window->show_all(); gtk::main(); ?> This is a example of gtkcombo, you can put the values of mysql query into $z array :-) > -- > PHP-GTK General Mailing List (http://gtk.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.gtk.general (#3201) next »