Re: Every field but Primary Key???

From: Date: Tue, 10 Oct 2000 22:51:59 +0000
Subject: Re: Every field but Primary Key???
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-3501@lists.php.net to get a copy of this message
I'm using mysql_fild_flags with no problems. Have a look on the on-line manual, this command returns a string with single word per flag separated by a single space check the explode() command. Jayme. http://www.conex.com.br/jjeffman -----Mensagem Original----- De: Lutz Brueckner <irie@gmx.de> Para: <php-db@lists.php.net> Enviada em: terça-feira, 10 de outubro de 2000 18:08 Assunto: Re: [PHP-DB] Every field but Primary Key??? > Wee Chua <Chua@mail.interclean.com> wrote: > > > Hi all, > > how could I display all fields but the primary keys after the join > > statement? Does anyone have any ideas about it? How to use the php codes to > > do this? Thanks for any help. > > there is no php-function that returns the primary keys. But what > about > > $res = mysql_query("SHOW KEYS FROM CaseEvent"); > while ($arr = mysql_fetch_array($res)) { > if ($arr["key_name"] == "PRIMARY") > $primary_keys[] = $arr["Column_name"]; > } > $res = mysql_query("SHOW KEYS FROM CaseType"); > while ($arr = mysql_fetch_array($res)) { > if ($arr["key_name"] == "PRIMARY") > $primary_keys[] = $arr["Column_name"]; > } > > > $sql = "SELECT * FROM CaseEvent, CaseType"; > > $result = mysql_query($sql, $db); > > $rows = mysql_num_rows($result); > > $fields = mysql_num_fields($result); > > while ($arr = mysql_fetch_array($result)) { > foreach($arr as $field => $value) { > if (!in_array($field, $primary_keys) { > echo $value; > } > } > } > > This is untested, but should do the job. > > Lutz > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#3501) next »