473,839 Members | 1,366 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HTML table Update row PHP/MySQL

Hi,

I have a dynamic HTML page with 4 columns of data, retrieved with PHP
from a MySQL database.
At the end of every row I have an UPDATE submit button, which activates
a php update script to update the database. I now encounter the problem
that in the update script I cannot trace back for which row the UPDATE
buttom was pressed.

I first had defined the UPDATE button as : <input name="update"
value="UPDATE" type="submit">. That doesn't work ...
If I change the definition to <input name="update" value=<? echo
"UPDATE".$n t['id']; ?type="submit"> , then I can get the id number in
the update script, but the display is not that good, because you see
UPDATE1, UPDATE7,UPDATE4 and so on ...
So I need something, so I can find back in the update script for which
row the update button was pressed. Each row has his unique id (which is
not shown in the table)

Anyone has a suggestion on how to solve this ?

Thanks in advance.

Jan 24 '07 #1
6 17882
Rik
On Wed, 24 Jan 2007 17:56:33 +0100, rukkie <ru****@belgaco m.netwrote:
I first had defined the UPDATE button as : <input name="update"
value="UPDATE" type="submit">. That doesn't work ...
If I change the definition to <input name="update" value=<? echo
"UPDATE".$n t['id']; ?type="submit"> , then I can get the id number in
the update script, but the display is not that good, because you see
UPDATE1, UPDATE7,UPDATE4 and so on ...
So I need something, so I can find back in the update script for which
row the update button was pressed. Each row has his unique id (which is
not shown in the table)

Anyone has a suggestion on how to solve this ?
'<input name="update['.$id.']" value="UPDATE" type="submit">'

In the update:
$id = intval(reset(ar ray_keys($_POST['update'])));
--
Rik Wasmus
* I'm testing several new newsreaders at the moment. Please excuse
possible errors and weird content. *
Jan 24 '07 #2
Thanks for the reply ....

Now I get some weird warning :

Warning: array_keys(): The first argument should be an array in
xxxx.php on line 9

and line 9 is the line with : $id =
intval(reset(ar ray_keys($_POST['update'])));

Any suggestion of what could be wrong ?
On 24 jan, 18:03, Rik <luiheidsgoe... @hotmail.comwro te:
On Wed, 24 Jan 2007 17:56:33 +0100, rukkie <ruk...@belgaco m.netwrote:
I first had defined the UPDATE button as : <input name="update"
value="UPDATE" type="submit">. That doesn't work ...
If I change the definition to <input name="update" value=<? echo
"UPDATE".$n t['id']; ?type="submit"> , then I can get the id number in
the update script, but the display is not that good, because you see
UPDATE1, UPDATE7,UPDATE4 and so on ...
So I need something, so I can find back in the update script for which
row the update button was pressed. Each row has his unique id (which is
not shown in the table)
Anyone has a suggestion on how to solve this ?'<input name="update['.$id.']" value="UPDATE" type="submit">'

In the update:
$id = intval(reset(ar ray_keys($_POST['update'])));
--
Rik Wasmus
* I'm testing several new newsreaders at the moment. Please excuse
possible errors and weird content. *
Jan 24 '07 #3
Message-ID: <11************ **********@s48g 2000cws.googleg roups.comfrom
rukkie contained the following:
>I first had defined the UPDATE button as : <input name="update"
value="UPDAT E" type="submit">. That doesn't work ...
If I change the definition to <input name="update" value=<? echo
"UPDATE".$n t['id']; ?type="submit"> , then I can get the id number in
the update script, but the display is not that good, because you see
UPDATE1, UPDATE7,UPDATE4 and so on ...
So I need something, so I can find back in the update script for which
row the update button was pressed. Each row has his unique id (which is
not shown in the table)

Anyone has a suggestion on how to solve this ?
One way is to make each row a separate form and use a hidden field. to
pass the id. Alternatively use checkboxes to get an array of ids and do
a multiple update with a single submit button.

--
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/
Jan 24 '07 #4
Rik
On Wed, 24 Jan 2007 18:23:36 +0100, rukkie <ru****@belgaco m.netwrote:
Thanks for the reply ....
Thank me by not topposting.
On 24 jan, 18:03, Rik <luiheidsgoe... @hotmail.comwro te:
>On Wed, 24 Jan 2007 17:56:33 +0100, rukkie <ruk...@belgaco m.netwrote:
I first had defined the UPDATE button as : <input name="update"
value="UPDATE" type="submit">. That doesn't work ...
If I change the definition to <input name="update" value=<? echo
"UPDATE".$n t['id']; ?type="submit"> , then I can get the id number in
the update script, but the display is not that good, because you see
UPDATE1, UPDATE7,UPDATE4 and so on ...
So I need something, so I can find back in the update script for which
row the update button was pressed. Each row has his unique id (which
is
not shown in the table)
Anyone has a suggestion on how to solve this ?'<input
name="update['.$id.']" value="UPDATE" type="submit">'

In the update:
$id = intval(reset(ar ray_keys($_POST['update'])));

Now I get some weird warning :

Warning: array_keys(): The first argument should be an array in
xxxx.php on line 9
Did you alter the name of the input like I told you?
The HTML-source should look like: '<input name="update[123]"
value="UPDATE"> ';
After posting, var_dump $_POST to see what it contains.

--
Rik Wasmus
* I'm testing several new newsreaders at the moment. Please excuse
possible errors and weird content. *
Jan 24 '07 #5
Hi,

thanks a lot.

At the end I've got it working with this part of code : <?echo "<input
name=\"update[".$nt['id']."]\""; ?>
Some quotes and/or double quotes makes the difference

Thanks !!

On 24 jan, 18:49, Rik <luiheidsgoe... @hotmail.comwro te:
On Wed, 24 Jan 2007 18:23:36 +0100, rukkie <ruk...@belgaco m.netwrote:
Thanks for the reply ....Thank me by not topposting.


On 24 jan, 18:03, Rik <luiheidsgoe... @hotmail.comwro te:
On Wed, 24 Jan 2007 17:56:33 +0100, rukkie <ruk...@belgaco m.netwrote:
I first had defined the UPDATE button as : <input name="update"
value="UPDATE" type="submit">. That doesn't work ...
If I change the definition to <input name="update" value=<? echo
"UPDATE".$n t['id']; ?type="submit"> , then I can get the id number in
the update script, but the display is not that good, because you see
UPDATE1, UPDATE7,UPDATE4 and so on ...
So I need something, so I can find back in the update script for which
row the update button was pressed. Each row has his unique id (which
is
not shown in the table)
Anyone has a suggestion on how to solve this ?'<input
name="update['.$id.']" value="UPDATE" type="submit">'
In the update:
$id = intval(reset(ar ray_keys($_POST['update'])));
Now I get some weird warning :
Warning: array_keys(): The first argument should be an array in
xxxx.php on line 9Did you alter the name of the input like I told you?
The HTML-source should look like: '<input name="update[123]"
value="UPDATE"> ';
After posting, var_dump $_POST to see what it contains.

--
Rik Wasmus
* I'm testing several new newsreaders at the moment. Please excuse
possible errors and weird content. *
Jan 24 '07 #6
Rik
On Wed, 24 Jan 2007 20:04:32 +0100, rukkie <ru****@belgaco m.netwrote:
thanks a lot.
You'd really thank me by starting to bottompost instead of toppost.
>'<input name="update['.$id.']" value="UPDATE" type="submit">'

In the update:
$id = intval(reset(ar ray_keys($_POST['update'])));
Now I get some weird warning :
Warning: array_keys(): The first argument should be an array in
xxxx.php on line 9Did you alter the name of the input like I told you?
The HTML-source should look like: '<input name="update[123]"
value="UPDATE" >';
After posting, var_dump $_POST to see what it contains.
At the end I've got it working with this part of code : <?echo "<input
name=\"update[".$nt['id']."]\""; ?>
Some quotes and/or double quotes makes the difference
That's why I said:
'<input name="update['.$id.']" value="UPDATE" type="submit">'
Seems a lot more readable then:
"<input name=\"update[".$nt['id']."]\"" value=\"UPDATE\ "
type=\"submit\" >";
--
Rik Wasmus
* I'm testing several new newsreaders at the moment. Please excuse
possible errors and weird content. *
Jan 24 '07 #7

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

Similar topics

6
6583
by: dev | last post by:
how create a temp table as a copy of a existing table and then update1 field and insert the hole temp table back in the existing table? please any help? if i have 10 fields in 1 record and about 100 records and a field.status=1 in a existing_table and i want to create a temp_table with all the recordse and values of the existing_table and then update the field.status to 2 and insert in 1 query the temp_table in the existing_table
7
5666
by: Gary | last post by:
I haver a table of students - Say 100 students that I need to be able to update/delete and amend. I know I can do this one student at a time which is simple but lets say I want to see all the students on the screen at the same time, modify some, mark some for deletion and even have blank fields at the end to add a new record. In HTML which is generated I label each row and input field with a name/number combination i.e <input type=text...
0
3813
by: Dan Jones | last post by:
How do I update a table to remove orphaned references to a second table? I've deleted rows in the second table, which has a unique auto_increment key. The first table now has references to keys that no longer exist. I need to update the first table, setting the value to NULL where the referenced key no longer exists. Something like: UPDATE table1 SET table2ID = NULL WHERE table1.table2ID NOT FOUND IN table2.ID; The NOT FOUND IN...
0
1874
by: Jim Moseby | last post by:
I stumbled across this while trying to update a table with a timestamp type column. At the time, I didn't know that the timstamp column would update itself when a row was changed. A kind gentleman in another group pointed that out to me. I added a column to a table and wanted to update the rows to populate the new column. When doing something like this I usually will create a temporary table and perform a dry run, just to make sure I am...
5
1772
by: elyob | last post by:
I'm just rewriting some backend management pages, in fact rewriting the whole database too. One of these pages has a simple HTML form to edit existing rows. I don't want to populate the form beforehand with all existing data. I just want to check which of the 20 fields have changed and update the data accordingly. Before (I wrote the script years ago, forgive me!), I just had a check whether any data in each field and each had its own...
3
4501
by: fjm67 | last post by:
I am new to PHP but not so new to Postgres. If someone can either direct me to some howto or even provide me with an example, I would be grateful. I would like to know if it is possible to create an HTML form text box that can draw information out of the database and display it in the HTML form text box. I have purchased a few books on the integration of Postgres and PHP but can find no such example. Maybe there is a better way of doing...
16
3507
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record in a hidden field) I wish the user to be able to edit the data in the table, so I have extracted the records into hiddenfield, textareas, dropdown list and checkbox so that they can make changes. I named these elements as arrays and wish to run an...
4
22592
by: Bob | last post by:
Hi all, I've got a table that I've imported and it has junk at the top of the table, so after import I run a delete query to remove the junk lines then I'm left with the field names I want for the table at the top of the table but the field names currently are 'field1' etc, so how do I rename the field names to the fields on the top row of the table. Cheers,
0
4445
by: silversubey | last post by:
I am trying to convert mssql triggers to mysql. I am very new to Mysql and would like some help with my code. My queries work but there has to be a more efficient way to write them. I would greatly appreciate any help. the following is a trigger that works until I add the last update statement. thanks for the help. Mysql 5 delimiter // Create TRIGGER User_Rating_Avg After Insert on bksite.Ratings FOR EACH ROW BEGIN UPDATE...
0
9856
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9698
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10910
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10654
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7833
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7021
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4493
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4066
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3136
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.