X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 71305D1F0D7 for ; Mon, 10 May 2004 09:18:05 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 95100-09 for ; Mon, 10 May 2004 09:17:47 -0300 (ADT) Received: from mail.exemail.com.au (mx2.exetel.com.au [220.233.0.3]) by svr1.postgresql.org (Postfix) with SMTP id 61229D1F0CB for ; Mon, 10 May 2004 09:17:41 -0300 (ADT) Received: (qmail 9835 invoked by uid 0); 10 May 2004 12:17:42 -0000 Received: from unknown (HELO exemail.com.au) (Paul.Lynch@exemail.com.au@220.233.5.231) by aich.exetel.com.au with SMTP; 10 May 2004 12:17:42 -0000 Message-ID: <409F7420.5060207@exemail.com.au> Date: Mon, 10 May 2004 22:22:56 +1000 From: Paul Lynch User-Agent: Mozilla/5.0 (Windows; U; Win95; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Yasmine Kedoo , pgsql-php@postgresql.org Subject: Re: Parsing Data, Table to Form References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200405/10 X-Sequence-Number: 2729 The task you are trying to do is easy enough once you understand the steps involved. From your example the following major steps (programs) are needed. 1. Display the data from the database in a table in HTML (admininfo.php) 2. Select one row from the table for update (I'm guessing this step is intended). 3. Display selected row in a form in HTML for operator update. (updaat.php) 4. Write changes made in 3 back to postgresql database table. (not_named_yet.php) My way of doing this (and there are many other ways to do this) is to have in step 2 the key or keys that will identify the row from the database in the html as hidden fields. echo ""; In the updaat.php program the hidden fields are assigned to php variables using the $_POST ["yourkeyid"] like: $keyforrow = $_POST["yourkeyid"]; You use the key to get the data again from the database and then display it in the new form for update. The final step involves the final php program picking up all the entered data from the form and updating the database, again the key to the database table may need to be hidden and assigned to variables. If this is where you are trying to go I can expand or send you some sample working php programs. Hope this helps, Paul Yasmine Kedoo wrote: > Hi again. > > I have carried out a search, then displayed the results in a table on > a php page called admininfo.php: > > $row = pg_fetch_object($result, 0); > > $test = ""; > > for ($rw = 0; $rw < $maxrows; $rw++) > { > echo " "; > > for ($fld = 0; $fld < $maxfields ; $fld++) > { > > echo " height=\"38\">"; > echo pg_Result($result,$rw,$fld); > $test .= pg_Result($result,$rw,$fld); > echo ""; > > echo "
\n"; > > } > echo " > "; > > } > > Now, i would like to parse the information displayed in the table to > textfields on the page updaad.php, i've used a link to do this: > > Update > > On the page updaad.php, i have displyed the textfields using the > following code: > > echo "Admin ID Number: value=\"$fld\">
\n"; > echo "Name:
\n"; > echo "Surname: value=\"$fld\">
\n"; > echo "Phone:
/>\n"; > echo "Email:
/>\n"; > echo "Username: value=\"$fld\">
\n"; > echo "Password: value=\"$fld\">
\n"; > echo "Building: value=\"$fld\">
\n"; > echo "Postcode: value=\"$fld\">
\n
"; > echo "
\n"; > > but i am unable to write the information displayed in the table in > admininfo.php, to the textfields in updaad.php. > > Has anybody got any suggestions? :-) > > Thanx > > Yaz > > > > >> From: brew@theMode.com >> To: Yasmine Kedoo >> Subject: Re: [PHP] Parsing Data, Table to Form >> Date: Sun, 9 May 2004 11:36:14 -0400 (EDT) >> >> >> Yaz...... >> >> > i want to be able to display the table information in editable form >> > fields, so that the data may be altered and the database updated. >> >> If by table information, you mean the information contained in the >> table, >> then what I do is get one row's data and load it into variables. I use >> the variables as the default text in the form (check the html standard). >> After the user makes any edits he updates the entire row. >> >> This only works with text boxes, with radio buttons and on/off >> buttons you >> have to generate different html depending on the existing button state. >> >> It's not complicated, just tedious to code if it has lots of >> buttons. If >> it's only text it's easier. I think I started with an example someone >> posted on php.net, maybe you can search for that and use it for >> reference, >> too. I think it has a subroutine to generate the buttons preselected by >> the existing state of the database. >> >> My script is long, involving switches to display the possible rows to be >> edited for a user on the first pass, then displaying the info for the >> row >> selected in an editable form, then updating (or inserting the row if it >> doesn't exist) and going back to displaying all the possible rows for >> that >> user. I have to study it for a while myself, remembering how it works >> before I make any changes to it! Hopefully somebody else has a more >> basic >> example. >> >> If by table information you mean the definition of a table in the >> database, then that would be diferent, although still involving somewhat >> the same type of script, just working on different database information. >> All my table definitions are static in my database, so I've never >> done it >> from a script, though. >> >> brew >>