By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,538 Members | 2,225 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,538 IT Pros & Developers. It's quick & easy.

Selecting Table row records for editing

P: n/a
Im not sure if this a PHP question or an MySQL question but here it goes.

I have a repeat region of a table called userid

What Im trying to accomplish is being able to edit the record and then
update it by clicking a submit button on the same line. Im doing it this
way so the user can quickly update a number of records one at a time. I know
I could do this by passing the userid info to a detail page but really want
to do it the way described. My problem is how do you select and then update
a specific row record ?

Thanks in advance.

Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
webhigh wrote:
Im not sure if this a PHP question or an MySQL question but here it goes.

I have a repeat region of a table called userid

What Im trying to accomplish is being able to edit the record and then
update it by clicking a submit button on the same line. Im doing it
this way so the user can quickly update a number of records one at a
time. I know I could do this by passing the userid info to a detail page
but really want to do it the way described. My problem is how do you
select and then update a specific row record ?


I do 'inline' editing in quite a few of my scripts. It often makes
things easier. The way to do that is as follows:

foreach ($userrecords as $userid => $userrecord) {
if ($userid == $_REQUEST['currentid']) {
# output the edit form for this record
} else {
# output a display row for this record
# ensure there is a link to $PHP_SELF?currentid=$userid
}
}

Then your initial display will be a page listing all your user records.
Click on the select link and you will get the same page with the chosen
record in a form for amendment. The form submit will then save your
changes and go back to the list. You can fiddle with currentid to select
the next record if you wish.
Jul 17 '05 #2

P: n/a
Selecting Table row records for editing
"webhigh" <we*****@attbi.com> wrote in message
news:BCAA8580.1285A%we*****@attbi.com...
I'm not sure if this a PHP question or an MySQL question but here it goes.

I have a repeat region of a table called userid

What I'm trying to accomplish is being able to edit the record and then
update it by clicking a submit button on the same line. I'm doing it this
way so the user can quickly update a number of records one at a time. I know
I could do this by passing the userid info to a detail page but really want
to do it the way described. My problem is how do you select and then update
a specific row record ?

----------------------------------------

What you can do is give each record a separate form, each with its submit
button. Say the records are listed in a table...

<table>
<tr>
<form action="save_record.php" method="post">
<td><input type ="text" name="name"></td>
...
<td><input type="hidden" name="userid" value="42">
<input type="submit" value="Save"></td>
</td>
</form>
</tr>

Save_record.php would changes to that record. Now here's the trick: if no
error was encountered, the script returns the HTTP status code 204 ("No
Content"). The browser's response to this is to keep the current page. No
refresh happens so you user doesn't lose the place s/he's at.
Jul 17 '05 #3

P: n/a
Selecting Table row records for editingIn my humble opinion your approach is all wrong. You should not allow updates on a list/browse form. Instead you should allow the user to select one or more entries on the current screen then press an UPDATE button which will go into a detail screen with its own SUBMIT button. If more than one record was selected you should display links which allow the user to step forwards and backwards through the selected items.

If you visit http://www.tonymarston.net/php-mysql...plication.html this will give you access to an online demonstration. You can then download the code and run it locally.

HTH

--
Tony Marston

http://www.tonymarston.net
"webhigh" <we*****@attbi.com> wrote in message news:BCAA8580.1285A%we*****@attbi.com...
I'm not sure if this a PHP question or an MySQL question but here it goes.

I have a repeat region of a table called userid

What I'm trying to accomplish is being able to edit the record and then update it by clicking a submit button on the same line. I'm doing it this way so the user can quickly update a number of records one at a time. I know I could do this by passing the userid info to a detail page but really want to do it the way described. My problem is how do you select and then update a specific row record ?

Thanks in advance.
Jul 17 '05 #4

P: n/a
On 4/21/04 6:37 AM, in article c6*******************@news.demon.co.uk, "Tony
Marston" <to**@NOSPAM.demon.co.uk> wrote:
In my humble opinion your approach is all wrong. You should not allow updates
on a list/browse form. Instead you should allow the user to select one or more
entries on the current screen then press an UPDATE button which will go into a
detail screen with its own SUBMIT button. If more than one record was selected
you should display links which allow the user to step forwards and backwards
through the selected items.

If you visit http://www.tonymarston.net/php-mysql...plication.html this
will give you access to an online demonstration. You can then download the
code and run it locally.

HTH


Thanks * It looks great would love to have something like this but I down
loaded the code and it is way beyond me. Which I could just upload and
select the table and the fields to show.

I kept getting the following:
This application has encountered an unrecoverable error

The following has been reported to the administrator:

2004-04-21 08:33:19

Fatal Error: MySQL error: 1044 : Access denied for user: 'value@localhost'
to database 'sample' (# 256).

Error in line 173 of file
'/home/value/public_html/phpapps/sample/std.dml.class.inc'.

Script: '/phpapps/sample/person_list.php'.

Object/Class: 'dml', Parent Class: ''.

Remote Address: (I deleted)

Warning: error_log(/home/value/public_html/errorlog.html): failed to open
stream: Permission denied in
/home/value/public_html/phpapps/sample/error.inc on line 88
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.