|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Problem to edit a record
I need somebody help me how to edit a record in PHP..
I have made this question in other time and with the answer I feel lost. but now I need to solve an urgent problem. I have a form with two field : ID and NAME and I save the information in a mysql DB, when I finish to fill and save all the record (like 15), I have a link to list all record showing the ID and the NAME. Until here I'm ok. But I found out, I have a record wrong and I need to edit this record to change it. I want a link in the ID field in the list I made, to click it and put this information in a form to edit. I don't know what code use to put the record in the form. I know that I need to use the UPDATE command to update the information in mysql, I know that, But I don't know how to put the information in the form. I want to know if I need to create a different form to put the information to edit or I use the same where I type the information the fist time.. If some body could help with this sending me an example with all the process, I'll very quite. I have problem with this.. Thanks Nestor Valdez nestor@ecreativodigital.com |
|
#2
|
|||
|
|||
|
do your query
PHP Code:
Code:
<input type="text" name="???" value="<?php echo $r['field']; ?>" />
__________________
-- Jason |
|
#3
|
|||
|
|||
|
Picking up from what Taelo wrote, when you get your form results back, instead of UPDATE, you could try REPLACE. That way you can use the same form.
With replace, if the record doesn't exist, it is created. If it exists, it is replaced. |
|
#4
|
|||
|
|||
|
I'm trying to edit a record.. this is my code, the file "registra.php" and "update.php"
REGISTRA.PHP ========== <form name="form1" method="get" action="update.php"> <input name="cia" type="text" id="cia" value="<?php echo $r['cia']; ?>"> <input name="nombrecia" type="text" id="nombrecia" value="<?php echo $r['nombrecia']; ?>" > <input name="lploto" type="text" id="lploto" value="<?php echo $r['lploto']; ?>"> <input name="Update" type="submit" id="update" value="Update"> ...... UPDATE.PHP ========= <? .... connection... $q = mysql("SELECT cia, nombrecia, lploto, FROM parametros WHERE cia= '{$_GET['cia']}'"); $r = mysql_fetch_array($q); ?> I type the number of 'cia', it is 1 and click UPDATE.. AND... it return me this error.. Warning: Wrong parameter count for mysql() in /home/mailcrea/public_html/loto/update.php on line 22 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mailcrea/public_html/loto/update.php on line 23 what happen with my code.. I just want to edit or update this record.. only typing the number of it and when I click update it put all the data and field in each field of the form.... |
|
#5
|
|||
|
|||
|
oops,...my fault
change "mysql" to mysql_query lol |
|
#6
|
|||
|
|||
|
thanks...
I haven't get update a record.. I have a lot time trying it. Ok.. not error, but when I submit. it go to the update.php. and it is blank... in the form i have : <form name="form1" method="get" action="update.php"> so it go to update.php... and it only have the code.. it must return to the form page with the data i'm retreiving.. what's wrong... I want to do this by first time, update a record..... what happen here.. Help me.... please..... I showed you the two files... REGISTRA.PHP and UPDATE.PHP TELL ME WHAT I MUST DO.. |
|
#7
|
|||
|
|||
|
on your update page, you will be using a form similar to the register page.
To fill the values in for editing, you need to echo the php variables back into an html form field. Code:
<input type="text" name="firstName" value="<?php echo $result['firstName']; ?>"> see how this works? |
|
#8
|
|||
|
|||
|
IĻm using 3 files to update...
the first with the form in blank, and when I submit I use the 2nd. then the 2nd. Look for the record and put the data in the form, I make the modififcation in the 2nd form and submit it and I use the 3rd script to Update the record. Iīm using this script to update a record in the 3rd script..... It process ok, and donīt report any error, but when I check the record it is NOT modifyed. $UpdRec = "UPDATE parametros SET cia='$cia', nombrecia='$nombrecia', lploto='$lploto', lplotopool5='$lplotopool5', lplotopool4='$lplotopool4', lppale12='$lppale12', lppale13='$lppale13', lppale23='$lppale23', lpquiniela1='$lpquiniela1', lpquiniela2='$lpquiniela2', lpquiniela3'$lpquiniela3', nppale12='$nppale12', nppale13='$nppale13', nppale23='$nppale23', npquiniela1='$npquiniela1', npquiniela2='$npquiniela2', npquiniela3='$npquiniela3' WHERE cia=1"; $r = mysql_query($UpdRec); what must happen.. |
|
#9
|
|||
|
|||
|
I really need your help...
I have a report showing some information... and at the end of each record I have a checkbox.. I need that when I click a check box of a record, and I click the submit botton it update the table and Move a "S" to the column updated o f this record... and I don't want it go to other page, I say that because when you put a script in the ACTION of the form it go to the page of this script.. I want it stay in the same page.. look at this... this is the page..I just want to move a "S" to the field called UPDATED when I select any record.. I don't know how to identify which record I'm selecting to move the "S" http://www.mailcreativo.com/loto/jugadas.php If it is possible.... |
|
#10
|
|||
|
|||
|
help please, I need to solve this problem..
I need to know How identify the record I checked.. to move the "S" in the UPDATED field in the table. |
|
#11
|
|||
|
|||
|
Hi guys, I'm still without to solve my problem trying to edit a record...
In this script I'm inserting a record after that, I needed to update a record and then I show the record with a select..... I need to know what happen, because it doesn't report me any error but it doesn't update the record.... I don't know how to do this, I still can update a record... $query = "INSERT INTO jugada(cuenta, fecha, hora, categoria, lpale1, lpale2, lpalevalor, procesado) VALUES ('$CUENTA', NOW(), localtime(), 3, '$numero1', '$numero2', '$valor', 'N')"; mysql_query($query) or die (mysql_error()); $query = "SELECT * FROM cliente WHERE cuenta='$CUENTA'"; $UpdateRecords = "UPDATE cliente SET balance = balance - $valor WHERE cuenta='$CUENTA'"; $result = mysql_query("SELECT j.cuenta, j.fecha, j.hora, c.categoria, j.lpale1, j.lpale2, j.lpalevalor FROM jugada j, categoria c WHERE j.categoria = c.id AND j.cuenta=('$CUENTA') AND j.categoria=3 AND j.lpale1='$numero1' AND j.lpale2='$numero2' AND j.lpalevalor=$valor"); $row = mysql_fetch_array($result); In other hand i posted a question about: how to edit a record where I'm using a select to show the information and at the end of each record I have a Checkbox and a submit button at the end of the report, and I want that when I check one or various record and click submit it save a "S" in one column of the record.. I need to now how Identify the record is check to be updated with the "S".. All my problems are trying to edit a record... |
|
#12
|
|||
|
|||
|
oh guys donīt you going to help me solve this problem.....
I really need it... |
|
#13
|
|||
|
|||
|
Hello Nestor,
It looks like you are having troubles understanding some basic concepts, because the answers posted before are good clues on how you should try to solve your problem... You say that you know how to use an "UPDATE" sql instruction, well, that's the main issue here, so you are half the way already. How to show the data so people can edit it? Well, in order to do this, you should know which record is going to be edited, right? Then you go and make a select in your database, which gives you a $row with all the fields needed. I can see you have this done too... Now you only need to place every result field in the corresponding form field, like this: PHP Code:
And what about the "Select", "radio" and "chackbox" fields? Well... is easy too. You just need to evaluate if the db field equals the value of the current form field... PHP Code:
It all depends on how your form is created and used... There are a lot of techniques to achieve this goal, you just need to understand how it works. Hope it helps (I don't know if you speak spanish, but if you do so, feel free to PM me and I can clarify anything about this in spanish) ![]()
__________________
The deal is not to know everything, but to know the email of the one who does. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Problem to edit a record |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|