Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #4004
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Arno Welzel <usenet@arnowelzel.de> |
| Newsgroups | comp.lang.php |
| Subject | Re: Edit a record? |
| Date | Sun, 04 Dec 2011 14:54:58 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 68 |
| Message-ID | <4EDB7BB2.20208@arnowelzel.de> (permalink) |
| References | <b543ef1a-9d25-4146-bee2-0f66ce61b364@v29g2000yqv.googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| Injection-Info | mx04.eternal-september.org; posting-host="9yN0DclMS8zFXFEoPPofhg"; logging-data="16891"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+C6nj9T0IszE0qqAaglZj8fNlN622RXcA=" |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20111105 Thunderbird/8.0 |
| In-Reply-To | <b543ef1a-9d25-4146-bee2-0f66ce61b364@v29g2000yqv.googlegroups.com> |
| Cancel-Lock | sha1:e5S6zW0Ye4kuS8w/F13w2lmACFs= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.php:4004 |
Show key headers only | View raw
Charles, 2011-12-03 14:28:
> I'm working on an application. I'm trying to implement an update
> process that pulls a record out of a MySQL database, updates it, and
> puts it back.
>
> Broken down, let's assume I have a database made up of the fields:
> First_name
> Last_name
> Month_of_birth
> Day_of_birth
> Year_of_birth
Why not a simple DATE field for birth date?
> The steps I'm finding so far are:
>
> 1) Present a data entry form to enter the values on which the record
> selection is based (an HTML form with 5 input fields...this I have).
> 1) Query the database for the record (Submit for processing to a PHP
> script that opensn the database and submits the values for a SELECT
> query).
>
> =========={this is where I am stuck]==============
>
> 3) Somehow import those returned values into a form for editting.
Why are you stuck? It's simple to output the values just using echo or
similar. E.g. if the first name fetched from the db is in $db_firstname:
<input
name="firstname"
type="text"
value="<?php echo htmlspecialchars($db_firstname); ?>" />
And if you want to present multiple records, just create names with an
index, starting with 0 and increased by 1 with every record:
<input
name="firstname[<?php echo $db_rownum; ?>]"
type="text"
value="<?php echo htmlspecialchars($db_firstname); ?>" />
> 4) Indicate somehow (in the form) which records (if more than one)
> need to be returned as updated to the MySQL database.
One possible way:
Pass the original values as hidden fields in the form, so you can
compare the modified fields with the original values.
OR:
Store the current values as session variables, so you can compare them
with the modified fields.
> 5) Somehow post to database
Just use an UPDATE statement in MySQL.
Maybe you should start by learnig the basics about SQL databases,
session handling and form handling in PHP.
--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Edit a record? Charles <cchamb2@gmail.com> - 2011-12-03 05:28 -0800
Re: Edit a record? Luuk <Luuk@invalid.lan> - 2011-12-03 14:45 +0100
Re: Edit a record? Denis McMahon <denismfmcmahon@gmail.com> - 2011-12-03 14:15 +0000
Re: Edit a record? "Beauregard T. Shagnasty" <a.nony.mous@example.invalid> - 2011-12-03 18:57 +0000
Re: Edit a record? Arno Welzel <usenet@arnowelzel.de> - 2011-12-04 14:54 +0100
Re: Edit a record? Dennis <nobody@nowhere.invalid> - 2011-12-04 09:14 -0500
Re: Edit a record? Charles <cchamb2@gmail.com> - 2011-12-10 05:02 -0800
Re: Edit a record? The Natural Philosopher <tnp@invalid.invalid> - 2011-12-10 19:22 +0000
csiph-web