Re: From form fields to postgres
| From: | Alan Knowles | Date: | Sun, 23 Sep 2001 14:48:03 +0000 |
| Subject: | Re: From form fields to postgres | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-147@lists.php.net to get a copy of this message | ||
guessing from the code you have,
$entries is not global, or local to this object.
try $this->entries
>----- Original Message -----
> From: John Starkey <jstarkey@advancecreations.com>
> To: php-gtk-general@lists.php.net
> Sent: Sat, 22 Sep 2001 23:04:47 -0600
> Subject: [PHP-GTK] From form fields to postgres
>
> Hello all. I just signed on to this list. I've been coding PHP for about a year and
> I've finally gotten around to learning php-gtk. I'm loving it.
>
> I've got a question regarding GtkEntry fields.
>
> I'm using:
>
> if ( $result = $DB->db_query( "SELECT * FROM clients" ) )
> {
> if ( $data =
$DB->db_fetch_array( $result, $x ) )
> {
> while( list( $key, $value ) = each( $data ) )
> {
> if ( $i % 2 )
> {
> // Not sure how to key this. I wanna try to keep the keys the same as
> the DB's column names.
> // What I'm using here isn't working.
> // entryField() just creates the text entry field and adds it from
> within that function.
> // $key is the label.
> $entries[$key] = $this->entryField( $key );
> }
> $i++;
> }
> }
> }
>
> $this->gui['AddButton'] = new GtkButton( 'Ok' );
> $this->gui['AddButton']->connect( 'clicked', array(
> &$this, 'addClient' ), $entries );
> $this->gui['b']->pack_start( $this->gui['AddButton'],
> true, true, 0 );
> $this->gui['b']->show();
>
> To get the form. And:
>
> function addClient( $entries )
> {
> $sql_beg = "INSERT INTO clients (";
> $sql_end = ") VALUES ('";
>
> // I was thinking that I could put keys in $name here. But it's not working.
> while ( list( $name, $value ) = each( $entries ) )
> {
> $sql .= $name.",";
> $sql_end .= $value."','";
> }
> $sql = $sql_beg.substr( $sql, 0, -1 ).substr( $sql_end, 0, -2 ).")";
> // The output of $sql is '' for each value and column name (obviously not
> very productive).
> echo $sql;
> }
>
> is what I'm try to do to get it into the DB. As a webby I'm used to just cycling
> through $HTTP_POST_VARS to get the keys and values.
>
> Is there a way to do something similar using GtkEntry results?
>
> TIA,
>
> John
>
>
>
> --
> PHP-GTK General Mailing List (http://gtk.php.net/)
> To unsubscribe, e-mail: php-gtk-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-gtk-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>
>