473,408 Members | 1,857 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,408 software developers and data experts.

Creating Multiple Record Update Forms

Hi,

I'm considering moving a payroll application out of Microsoft Access to some
web-based solution. It is getting way to big for Access and the system is
growing unstable, so I'm learning PHP and MySQL and things are looking very
promising.

There is one piece of this I am having problems with. The attendance module
shows users all their employees in a table and allows them edit it this way.
My users need to be able to see and update all their employee records at
once, and they need to do it quickly, so they can't wait to load one
employee at a time.

So they would see something like this:

Clock Date Hours OT Absent
123 7/7/04 8 0 0
456 7/7/04 9 1 0
789 7/7/04 5 0 3
987 7/7/04 0 0 8

They would be able to update the Hours, OT, and Absent fields, and they
should be able to insert records.

I can figure out how to do a single record update form (like the one you get
with the Update Form wizard in Dreamweaver), but not a multiple record
update form. That is just not practical.

I think I can make each row a form and put an update button at the end. I've
seen this done on some web sites and that might work, but it could still be
too slow. What I would like to do is have one update button at the end of
the form that would send all the records back to the server (or maybe just
those that were changed). Does anyone know if this is possible and have any
pointers on how it is done? Even directions to a good web resource for this,
or a book would be appreciated.

Thanks,
Rob

Jul 17 '05 #1
5 5191
I noticed that Message-ID: <BD*********************@yahoo.com> from R
Duncan contained the following:
What I would like to do is have one update button at the end of
the form that would send all the records back to the server (or maybe just
those that were changed). Does anyone know if this is possible and have any
pointers on how it is done? Even directions to a good web resource for this,
or a book would be appreciated.


Include the record id as a hidden field.
<input type="hidden" name="id[]" value="id from database">

Make the fields you want to update into arrays. e.g. <input
type="textbox" name="hours_worked[]"value=" Hours_worked from database>

for($i=0;$i<count($_POST["id"]);$i++){
$hw=$_POST["hours_worked"][$i];
$id=$_POST["id"][$i]
$pdate=mysql_query("UPDATE table SET hours_worked='$hw'
WHERE id=$id");
}

add more fields to same loop as necessary

Apparently there is no problem updating all records since MySql will
ignore those that haven't changed.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message
news:hl********************************@4ax.com...
I noticed that Message-ID: <BD*********************@yahoo.com> from R
Duncan contained the following:
What I would like to do is have one update button at the end of
the form that would send all the records back to the server (or maybe justthose that were changed). Does anyone know if this is possible and have anypointers on how it is done? Even directions to a good web resource for this,or a book would be appreciated.


Include the record id as a hidden field.
<input type="hidden" name="id[]" value="id from database">

Make the fields you want to update into arrays. e.g. <input
type="textbox" name="hours_worked[]"value=" Hours_worked from database>


Not a good idea for the simple reason you can't guarentee that the browser
will return hours_worked[] in the same order as id[].

For each field on row embed the row id in the field name

<input type="text" name="hoursworked_$id" value="$hoursworked">

foreach($_POST AS $k => $v)
{
/*
check for each field in the row by writing a reg expr
*/
if(preg_match("^hoursworked_" , $k))
{
list($ignore , $id) = split("_" , $k)
{
$aPayroll[$id][HOURS_WORKED] = $v;
}
}
}

Jul 17 '05 #3
I noticed that Message-ID: <cc**********@slavica.ukpost.com> from CJ
Llewellyn contained the following:
Include the record id as a hidden field.
<input type="hidden" name="id[]" value="id from database">

Make the fields you want to update into arrays. e.g. <input
type="textbox" name="hours_worked[]"value=" Hours_worked from database>


Not a good idea for the simple reason you can't guarentee that the browser
will return hours_worked[] in the same order as id[].


In which case you could simply use a counter (hours_worked[$i] id[$]) to
make sure.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4
"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message
news:ou********************************@4ax.com...
I noticed that Message-ID: <cc**********@slavica.ukpost.com> from CJ
Llewellyn contained the following:
Include the record id as a hidden field.
<input type="hidden" name="id[]" value="id from database">

Make the fields you want to update into arrays. e.g. <input
type="textbox" name="hours_worked[]"value=" Hours_worked from database>


Not a good idea for the simple reason you can't guarentee that the browserwill return hours_worked[] in the same order as id[].


In which case you could simply use a counter (hours_worked[$i] id[$]) to
make sure.


How would you know the start and end points?

You could query the payroll table to see what rows should have been returned
by the form.

Better still, store them in a session array.


Jul 17 '05 #5
I noticed that Message-ID: <cc**********@slavica.ukpost.com> from CJ
Llewellyn contained the following:
In which case you could simply use a counter (hours_worked[$i] id[$]) to
make sure.


How would you know the start and end points?


Well I'd like to leave the OP something to do, but I was thinking
something like this:-

$i=0
while($myrow=$mysql_fetch_array($result)){

print "<input
type=\"textbox\"name=\"hours_worked[$i]\"value=\"".$myrow['hours_worked']."\">";
print"<input type=\"hidden\"name=\"id[$i]\"
value=\"".$myrow['row_id']."\">";
$i++
}

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matthew Clubb | last post by:
Hi, I need help developing an expanding form I've decided that a use of PHP, Mysql and Javascript is the best platform for creating a selection of database interfaces which I'm trying to build...
2
by: Iain Miller | last post by:
Now this shouldn't be hard but I've been struggling on the best way as to how to do this one for a day or 3 so I thought I'd ask the assembled company..... I'm writing an application that tracks...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
6
by: F-13 | last post by:
I'm working on a BOM in Access 200 from an example downloaded from from the web. The sample database contains three tables, Assemblies (the list of items needed to assemble any assembly),...
10
by: Marc R. | last post by:
Hi all, I edit records using a form that have multiple control bind on Dataview, But I don't want to update right always to database, I would like to delay until all Changes (add all new...
3
by: jpr | last post by:
Hello, I know that this is not the rule but need some help. My datbase has three tables: MASTER TEMPLATES FORMS I have a form which is based on a table named MASTER. I have a primary key...
7
by: bcap | last post by:
hi, I am trying to create a form where you may have more than one person at a meeting, but want to have them be related to the same meeting. I have a mulitple select text area and if you...
0
by: emalcolm_FLA | last post by:
Hello and TIA for any help with this non profit Christmas assistance project. I have an applicant (app history) and child (child history) tables (4 total). I need to grab the next available (in...
1
by: isoquin | last post by:
Hello- I have one form frmProject1 (record source tblProject1), with two subforms within it: 1) frmPayroll (tblPayroll), and 2) frmTimes (tblTimes) Basically, there are multiple different...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.