|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
edit data in PHP
Hi,
I have created a PHP script where it can allow me to add, edit , delete data on mysql table then display it on a browsers. I have already made the add, delete script running except for the edit script. my edit script should be able to edit existing data or add new data however i can view the page when i clicked the edit button but it doesnt update the datas on my table...can someone help me.... below is my script<?php // if the enter information is clicked if ($submit == "Enter information") { $subject = $_POST['subject']; $message = $_POST['message']; $TSE = $_POST['TSE']; $connect = mysql_connect('localhost', 'aries', 'chikos'); $dbase = mysql_select_db('cabron'); $sql = "INSERT into post (subject, message, TSE) VALUES ('$subject', '$message','$TSE')"; $result = mysql_query($sql); } //if the update information button is clicked else if($update == "Update information") { $subject = $_POST['subject']; $message = $_POST['message']; $TSE = $_POST['TSE']; $connect = mysql_connect('localhost', 'aries', 'chikos'); $dbase = mysql_select_db('cabron'); $sql = "UPDATE post SET subject = '$subject', message = '$message', TSE = '$TSE' WHERE id = $id"; $display = mysql_query($sql); echo 'UPDATED'; } //displays the data to be edited else if ($id) { $id = $_POST['id']; $connect = mysql_connect('localhost', 'aries', 'chikos'); $dbase = mysql_select_db('cabron'); $query = mysql_query("SELECT * FROM post WHERE id = '$id'"); $display = mysql_fetch_array($query); ?> <form method = "POST" action = "<?php echo $PHP_SELF?>"> <input type = "hidden" name = "id" value = "<?php echo $display['$id']?>"> Subject: <input type = "text" name = "subject" value="<?php echo $display['subject']?>"><br> Message: <textarea name = "message" rows = "20" cols = "80" wrap = "virtual" value = "<php? php echo $display['message']?>"></textarea><br> Posted by: <input type = "text" name = "TSE" value="<?php echo $display['TSE']?>"><br> <input type = "submit" name = "update" value = "Update information"> </FORM> <? } else { ?> <form method = "post" action = "<?php echo $PHP_SELF?>"> Subject:<input type = "text" name = "subject"><br> Message:<textarea name = "message" rows = "5" cols = "40" wrap = "virtual"></textarea><br> Posted by:<input type = "text" name = "TSE"><br> <input type = "submit" name = "submit" value = "Enter information"></form> <? } ?> |
|
#2
|
|||
|
|||
|
The following line (please look closely and compare):
Quote:
Leads me to believe you want to compare the text in the submit button... but the submit button's name is not "submit"... its name is "update", so your line should read: PHP Code:
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. Last edited by laidbak : June 18th, 2003 at 11:40 AM. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > edit data in PHP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|