Re: Select box equiv

From: Date: Thu, 03 Apr 2003 09:31:32 +0000
Subject: Re: Select box equiv
References: 1 2 3  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-3209@lists.php.net to get a copy of this message
----- Original Message ----- From: "Madeleine D." <mmdrake@bctonline.com> To: "epplestun" <epplestun@alaplaya.com>; <php-gtk-general@lists.php.net> Sent: Wednesday, April 02, 2003 8:04 PM Subject: Re: [PHP-GTK] Select box equiv > I appreciate the sample. It helps a lot. > > Can you elaborate on the item inside the while loop? What do we refer to > in '$row["something"]? Right now, running the sample with our mysql info > causes a Win protection fault. > > thanks > Madeleine D. > what version of phpgtk do you have?¿ in my pc i dont have any problem :( the example i runed in win plataform. > > At 12:28 PM 4/2/2003 +0200, you wrote: > > > >----- 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 > >> > > > > > >-- > >PHP-GTK General Mailing List (http://gtk.php.net/) > >To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > PHP-GTK General Mailing List (http://gtk.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

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