Re: Select box equiv
| From: | Madeleine D. | Date: | Wed, 02 Apr 2003 18:04:55 +0000 |
| Subject: | Re: Select box equiv | ||
| References: | 1 2 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-3207@lists.php.net to get a copy of this message | ||
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.
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
>
>