Re: Every field but Primary Key???

From: Date: Tue, 10 Oct 2000 21:08:03 +0000
Subject: Re: Every field but Primary Key???
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-3497@lists.php.net to get a copy of this message
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

« previous php.db (#3497) next »