473,398 Members | 2,393 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,398 software developers and data experts.

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".$nt['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 17855
Rik
On Wed, 24 Jan 2007 17:56:33 +0100, rukkie <ru****@belgacom.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".$nt['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(array_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(array_keys($_POST['update'])));

Any suggestion of what could be wrong ?
On 24 jan, 18:03, Rik <luiheidsgoe...@hotmail.comwrote:
On Wed, 24 Jan 2007 17:56:33 +0100, rukkie <ruk...@belgacom.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".$nt['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(array_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**********************@s48g2000cws.googlegroups .comfrom
rukkie contained the following:
>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".$nt['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****@belgacom.netwrote:
Thanks for the reply ....
Thank me by not topposting.
On 24 jan, 18:03, Rik <luiheidsgoe...@hotmail.comwrote:
>On Wed, 24 Jan 2007 17:56:33 +0100, rukkie <ruk...@belgacom.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".$nt['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(array_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.comwrote:
On Wed, 24 Jan 2007 18:23:36 +0100, rukkie <ruk...@belgacom.netwrote:
Thanks for the reply ....Thank me by not topposting.


On 24 jan, 18:03, Rik <luiheidsgoe...@hotmail.comwrote:
On Wed, 24 Jan 2007 17:56:33 +0100, rukkie <ruk...@belgacom.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".$nt['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(array_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****@belgacom.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(array_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
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...
7
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...
0
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...
0
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...
5
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...
3
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...
16
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...
4
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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
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...

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.