Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,407 members, 7,954,612 topics. Date: Saturday, 21 September 2024 at 01:11 AM |
Nairaland Forum / Science/Technology / Programming / Help With PHP MYSQL(UPDATE) (1387 Views)
10 Nights Of Cloning Nairaland With PHP / Lets Start A Real Web-deveopment Course Here Html+css+javascript+php+mysql / Creating A Group Chat With Html/javascript/php/mysql For Beginners (2) (3) (4)
Help With PHP MYSQL(UPDATE) by ivcraig(m): 3:18pm On Jan 28, 2015 |
Guys, I'm making a database program in PHP. I have got everything working, from the inserting, deleting, and viewing records. But I can't get Updating records to work. I want the user to be able to click on "Edit button" GETing the previous records and make changes then update. Thanks. |
Re: Help With PHP MYSQL(UPDATE) by codemarshal08(m): 5:36pm On Jan 28, 2015 |
what code have u tried ? |
Re: Help With PHP MYSQL(UPDATE) by ivcraig(m): 6:42pm On Jan 28, 2015 |
Thanks. I tried sending the row I'd with my edit button on the page where my database entries are in a loop. Echo '<td><a href="edit.php?id=' . $row['id'] .'">Edit</a></td>'; On the edit.php page I tried..... 1: creating a form with the input values as php echo $_POST['some row from the table I'm working on'] |
Re: Help With PHP MYSQL(UPDATE) by Nobody: 7:29pm On Jan 28, 2015 |
UPDATE `table` SET `column name`='newdata' WHERE `column`='blah blah' |
Re: Help With PHP MYSQL(UPDATE) by ivcraig(m): 7:39pm On Jan 28, 2015 |
Jregz:Nice one. Buh I'm trying to retrieve records and display them in a fieldset before updating |
Re: Help With PHP MYSQL(UPDATE) by codemarshal08(m): 8:13pm On Jan 28, 2015 |
ivcraig: *use a SELECT statement to retrieve this info from ur db *store this info in variables *attach these variables to your form values while displaying them *Ehm, are u getting errors from ur code or u are looking for the Edit Record Logic ? |
Re: Help With PHP MYSQL(UPDATE) by Nobody: 8:27pm On Jan 28, 2015 |
ivcraig:it has been answered by the poster above me,do remember to add the PHP tag before echoing the variable, else na so so dollar sign go full your web app |
Re: Help With PHP MYSQL(UPDATE) by ivcraig(m): 8:29pm On Jan 28, 2015 |
codemarshal08:Thanks CodeMarshal. Just what I need, the Edit Record Logic. |
Re: Help With PHP MYSQL(UPDATE) by codemarshal08(m): 8:38pm On Jan 28, 2015 |
ivcraig: Lets Assume i want to edit user with ID 603, i will create two pages Edit.php and update.php (Note: You can as well use a Page for both) in Edit.php, * store this id in a variable , like: $userID = 603; * then use this id in the WHERE clause of ur SELECT statement like: SELECT something from TABLE WHERE id = 603 * retrieve the result result using: mysql_fetch_array or stuff like that o * save ur values u got from DB QUERY in variables like $username = $row["username"]; $dept = $row["dept"]; * echo out ur form by attaching those variable u saved to the html tags like: echo"<form action='edit' method='POST'>"; echo"<input type ='text' name='username' value='$username' />"; echo"<input type ='text' name='dept' value='$dept' />"; * Attach the id to a hidden text field (so u can retrieve it in the next page) something like: <input type=''hidden' name='userID' value=$userID> * remember to add a submit button to ur form o In Update.php * retrieve form value i guess u can do this (hint: POST) * use these values to update ur DB hint: using UPDATE statement 1 Like |
Re: Help With PHP MYSQL(UPDATE) by ivcraig(m): 10:06pm On Jan 28, 2015 |
codemarshal08:Wow! Thanks... Lemme quickly follow ur steps. Testimony loading.... |
Re: Help With PHP MYSQL(UPDATE) by ivcraig(m): 12:27am On Jan 29, 2015 |
Codemarshal08, thank you so much for this piece of code. It worked smoothly like a charm. Bros lemme have u on speed dial, I've got a lot to learn from you. My Sensei. |
Re: Help With PHP MYSQL(UPDATE) by codemarshal08(m): 5:53am On Jan 29, 2015 |
ivcraig:i am glad u got the idea . my mail : com(dot)gmail(at)codemarshal08 (READ FROM right to Left) |
Re: Help With PHP MYSQL(UPDATE) by ivcraig(m): 8:02am On Jan 29, 2015 |
codemarshal08:You are a real Code Marshal. Nice one. Added to my contacts. |
(1) (Reply)
Object-oriented PHP / Hlp Tips On Developing Second School Web Apps In Nigeria / To Whom It May Concern.
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 30 |