|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
What wrong? Editing a row in mysql
I am having a problem with editing a row in mysql. The script i wrote out seems to show up. It gives me a validation that it has been completed. No parse errors or anything, but it seems that it just doesnt update the new part into teh databse. (I got this method from spoono) lemme add it:
<form action="<? echo $PHP_SELF ?>" method="post"> <? mysql_pconnect("localhost","******","******"); //enter name and password mysql_select_db("central"); //select the database if(!$cmd) { $result = mysql_query("select * from data"); //replace news with your table name while($r=mysql_fetch_array($result)) { $title=$r["title"]; $name=$r["name"]; $article=$r["article"]; $id=$r["ID"]; ?> ?> <INPUT TYPE="RADIO" NAME="id" VALUE="<?php echo $id;?>"><? echo $id;?> <? echo $title ?><br> <? } ?> <input type="submit" name="cmd" value="edit"></form> <? } ?> <? if($cmd=="edit") { if (!$submit) { $sql = "SELECT * FROM data WHERE id=$id"; //replace news with your table name above $result = mysql_query($sql); $myrow = mysql_fetch_array($result); ?> <input type=hidden name="id" value="<?php echo $myrow["id"] ?>"> Title:<INPUT TYPE="TEXT" NAME="title" VALUE="<?php echo $myrow["title"] ?>" SIZE=30><br> Article:<TEXTAREA NAME="article" ROWS=10 COLS=30><? echo $myrow["article"] ?></TEXTAREA><br> Name:<INPUT TYPE="TEXT" NAME="name" VALUE="<?php echo $myrow["name"] ?>" SIZE=30><br> <input type="hidden" name="cmd" value="edit"> <input type="Submit" name="submit" value="Post Comment"> </form> <? } ?> <? if($submit) { $sql = "UPDATE `data` SET `title`='$title',`article`='$article',`name`='$nam e' WHERE id=$id"; //replace news with your table name above $result = mysql_query($sql); echo "Thank you! Information updated."; } } ?> |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > What wrong? Editing a row in mysql |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|