Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #3996 > unrolled thread
| Started by | Charles <cchamb2@gmail.com> |
|---|---|
| First post | 2011-12-03 05:28 -0800 |
| Last post | 2011-12-10 19:22 +0000 |
| Articles | 8 — 7 participants |
Back to article view | Back to comp.lang.php
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
| From | Charles <cchamb2@gmail.com> |
|---|---|
| Date | 2011-12-03 05:28 -0800 |
| Subject | Edit a record? |
| Message-ID | <b543ef1a-9d25-4146-bee2-0f66ce61b364@v29g2000yqv.googlegroups.com> |
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
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.
4) Indicate somehow (in the form) which records (if more than one)
need to be returned as updated to the MySQL database.
5) Somehow post to database
Anyone have any ideas they'd care to share?
[toc] | [next] | [standalone]
| From | Luuk <Luuk@invalid.lan> |
|---|---|
| Date | 2011-12-03 14:45 +0100 |
| Message-ID | <folpq8-tf9.ln1@luuk.invalid.lan> |
| In reply to | #3996 |
On 03-12-2011 14:28, Charles wrote:
> 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
>
> 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.
> 4) Indicate somehow (in the form) which records (if more than one)
> need to be returned as updated to the MySQL database.
> 5) Somehow post to database
>
> Anyone have any ideas they'd care to share?
show the code you have so far,
and specify more exact why 'you are stuck'....
--
Luuk
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2011-12-03 14:15 +0000 |
| Message-ID | <4eda2f17$0$29349$a8266bb1@newsreader.readnews.com> |
| In reply to | #3996 |
On Sat, 03 Dec 2011 05:28:42 -0800, Charles wrote:
> 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. 4)
> Indicate somehow (in the form) which records (if more than one) need to
> be returned as updated to the MySQL database. 5) Somehow post to
> database
>
> Anyone have any ideas they'd care to share?
A select query assembled using the data submitted in your form (perhaps
the name data) and selecting the date of birth data from the table
don't forget to escape any parameters from the form that you use in a
query, also you might want to validate names (alphabetics, spaces,
hyphens, possibly ' characters eg O'Leary) and dates (numerics only).
You might use an html "select" and option list for the month?
Anyway, use mysql / myslqli / pdo functions (your choice, it's up to you
at this point) to open and interrogate the db to read the record you want
to edit, then display that record in a form using the value attribute or
the selectedindex of the various html form elements to display the data
you want to edit.
Then, once the data is edited and submitted, the next script will update
the records in the table.
If you look in the php documentation for the relevant database functions
there are a lot of examples.
Rgds
Denis McMahon
[toc] | [prev] | [next] | [standalone]
| From | "Beauregard T. Shagnasty" <a.nony.mous@example.invalid> |
|---|---|
| Date | 2011-12-03 18:57 +0000 |
| Message-ID | <jbdrfg$a9$2@dont-email.me> |
| In reply to | #3996 |
Charles wrote: > I'm working on an application. I'm trying to implement an update > [snip] > Month_of_birth > Day_of_birth > Year_of_birth > > Anyone have any ideas they'd care to share? Why the three separate fields? Just use a single DATE field (name it DOB or similar) and if/when you need to report on it, simply pull out the month or day or year parts in your SELECT query. Much easier to maintain. Trying to arrange, say, a sort by birthdate with your method is much more difficult. -- -bts -This space for rent, but the price is high
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2011-12-04 14:54 +0100 |
| Message-ID | <4EDB7BB2.20208@arnowelzel.de> |
| In reply to | #3996 |
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
[toc] | [prev] | [next] | [standalone]
| From | Dennis <nobody@nowhere.invalid> |
|---|---|
| Date | 2011-12-04 09:14 -0500 |
| Message-ID | <svvmd75o9fuhj2ndre59otg0ogsmcbqpdk@4ax.com> |
| In reply to | #4004 |
On Sun, 04 Dec 2011 14:54:58 +0100, Arno Welzel <usenet@arnowelzel.de> wrote: >Maybe you should start by learnig the basics about SQL databases, >session handling and form handling in PHP. It sounds like someone's homework to me. -- Dennis
[toc] | [prev] | [next] | [standalone]
| From | Charles <cchamb2@gmail.com> |
|---|---|
| Date | 2011-12-10 05:02 -0800 |
| Message-ID | <3cba1373-0920-4ab8-bb7f-fabff209476a@z12g2000yqm.googlegroups.com> |
| In reply to | #4004 |
I have the process down to a fine science in getting data to the
database from the user interface, and I have it down for generating
basidc reports to a printer. I've also designed closed database
applications in the past, so they are not new to me.
Designing a web interface is what's new. Care to recommend any good
references for this part of the project?
On Dec 4, 6:54 am, Arno Welzel <use...@arnowelzel.de> wrote:
> 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 Welzelhttp://arnowelzel.dehttp://de-rec-fahrrad.de
>
>
[toc] | [prev] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2011-12-10 19:22 +0000 |
| Message-ID | <jc0bhs$vv0$1@news.albasani.net> |
| In reply to | #4046 |
Charles wrote: > I have the process down to a fine science in getting data to the > database from the user interface, and I have it down for generating > basidc reports to a printer. I've also designed closed database > applications in the past, so they are not new to me. > > Designing a web interface is what's new. Care to recommend any good > references for this part of the project? > Seriously you don't need them. Just understand a bit about how the browser form and server side code interact, and then get coding. Expect top rewrite the first app when you learn a little more, but don't stop doing it. Its probably best to hack first learn later until you have got the fundamental features sorted, then go back to the manuals to find out where you really should have been more careful. I.e. hacking a script is a fast way to learn, then expect to rewrite it PROPERLY later AFTER you have read a few manuals. .
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web