Jump to content

updating multiple queries in php


Kevin Castro

Recommended Posts

I want to update more than one column in php using mysql.

 

fr example:

$sql="update table_name set where username='$user';

 

$sql="update table_name set where password='$pass';

 

how to concatenate this querie?

 

could you tell anyone how to solve this?

 

Thanks in advance

Link to comment
Share on other sites

just more than one column but still one table right !

 

here is my query just give comma

UPDATE  `tabel_annual` SET  `tglmulai` =  '$tanggalmulai',`tglakhir` =  '$tanggalakhir',`acara` =  '$acara',`id_lokasi` =  '$lokasi',`tarip` =  '$tarif',`ket` =  '$keterangan',`cp` =  '$cp',`status` =  '$cek' WHERE  `tabel_annual`.`id_anual` ='$id'

Hope this make sense

 

sorry edited what do you mean multi query ! i saw your query trying update same table, please more detail what you want to

 

Freddy

Edited by dauruk0512
Link to comment
Share on other sites

fr eg:) i created 4 input tags namely username,update username,password and update password.

 

i want to update old username into new username and old password into new password.

 

here is the code for updating single column in php

 

$sql="update students set where username='$user';

 

if i update password field how to combine with this same variable....

Link to comment
Share on other sites

sorry for late respond, you are write wrong query kevin !

 

if you want to update row in table, you need to post primary key too which show in your edit.php cause it need in your query clasue where,

 

so your query wrong, i guess this is not change at all you data in table cause you need set each table !

update students set where username='$user

here is my query suggest to you why there is id_user in my query because id_user is primary key, $usernmae, $password, $id is variabel came from your form, in this case you need show id_user in your form so you can update it,

UPDATE  `students ` SET  `username` =  '$username',`password` =  '$password' WHERE  `id_user` ='$id'

so here is simple table from me ->id_user, usernmae, password

 

 

oh ya almost forgot if you need encrypt your password you need md5 when you post password

 

 

 

Hope this make sense, please let me know if working, Thanks

 

 

Freddy

Link to comment
Share on other sites

MD5 is not a secure way to encrypt passwords. From the PHP manual itself:

http://php.net/md5

Note: Secure password hashing It is not recommended to use this function to secure passwords, due to the fast nature of this hashing algorithm. See here for details.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...