From form fields to postgres

From: Date: Sun, 23 Sep 2001 05:04:47 +0000
Subject: From form fields to postgres
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-146@lists.php.net to get a copy of this message
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

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