I have my hidden id

<input type="hidden" name="id" value="<?php echo "$id" ?>" />

in my form

I have my

$id = $_REQUEST['id'];

to get the id from the url

And on the update script i have

$navtype = $_GET['nav'];

And i have

WHERE id=$id

, but it keep updating just one record over and over,no matter which record i select.

When i make the hidden text, i see the right id

<input type="text" name="id" value="<?php echo "$id" ?>" />

.

I echo

"$sql";

, and the value is always one

UPDATE persoz SET lname='Daniel',fname='Ekow Gilbert Jr.',p_no='012012',todate='2011-01-01', WHERE id=1
Member Avatar for diafol

I'm a bit confused. You're using a form to send the id, by you say that it's coming from the url. Do you have a method attribute in the form tag? The default is get, but it's usually taken that form data should be sent by post. Also, don't use $_REQUEST - it's not very secure (cookies, post and get can use it - you should use the specific type).

Firstly:

UPDATE persoz SET lname='Daniel',fname='Ekow Gilbert Jr.',p_no='012012',todate='2011-01-01', WHERE id=1

is wrong - there should not be a comma before the WHERE clause.

UPDATE persoz SET lname='Daniel',fname='Ekow Gilbert Jr.',p_no='012012',todate='2011-01-01' WHERE id=1

I'm a bit confused. You're using a form to send the id, by you say that it's coming from the url. Do you have a method attribute in the form tag? The default is get, but it's usually taken that form data should be sent by post. Also, don't use $_REQUEST - it's not very secure (cookies, post and get can use it - you should use the specific type).

Firstly:

UPDATE persoz SET lname='Daniel',fname='Ekow Gilbert Jr.',p_no='012012',todate='2011-01-01', WHERE id=1

is wrong - there should not be a comma before the WHERE clause.

UPDATE persoz SET lname='Daniel',fname='Ekow Gilbert Jr.',p_no='012012',todate='2011-01-01' WHERE id=1

I did just that,replace the comma,but no result.
Are you saying i should use $_GET in place of $_REQUEST ?

Member Avatar for diafol

Depends on how you're sending the form data. $_GET or $_POST don't use $_REQUEST. However, I can't see how that would sort out the $id value though. Post the whole code snippet.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.