473,385 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Selecting Table row records for editing

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 #1
4 3642
webhigh wrote:
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 ?


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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Oren | last post by:
Hi, I have an Access application with linked tables via ODBC to MSSQL server 2000. Having a weird problem, probably something i've done while not being aware of (kinda newbie). the last 20...
28
by: Lee Rouse | last post by:
Hello all, This is going to be a rather lengthy "question". I have an Access 2k database, separated front end/back end. Front end copies are on about 30 workstations and used frequently during...
0
by: allyn44 | last post by:
HI--I have 2 tables Cut: cut ID, HistNumb, Block, date: Cut Id is the primary key, the other 3 fileds are indexed to be unique Slides: Cutid SlideID, and various other fields: there can be...
1
by: Ramesh | last post by:
hi, I am selecting fields from three table for manupulating data and i want to display total number of records selected. But i am always getting -1 value, eventhough 1000 of records are selected....
48
by: phillip.s.powell | last post by:
MySQL 3.23.58 - 4.0.17 (yep, several database server instances, don't ask) I have database Spring with table Students I have database Summer with table Students I am tasked to produce a...
2
by: Catch_22 | last post by:
Hi, I have a stored procedure that has to extract the child records for particular parent records. The issue is that in some cases I do not want to extract all the child records only a...
4
by: J | last post by:
I am editing a pre-existing view. This view is already bringing data from 40+ tables so I am to modify it without screwing with anything else that is already in there. I need to (left) join it...
2
by: movieking81 | last post by:
If someone could help me with this, that would be great. I need to select a number of records from an SQL table based on a date range, so I started with this select. <html> <code> resultssql =...
2
by: Gord | last post by:
Is it possible to get a table type grid to appear on a custom dialog form? Basically, get the same thing as when you open a table in Datasheet view and can edit the individual columns. I'd like to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.