SunQuest
 
           PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old June 18th, 2003, 06:06 AM
cabron cabron is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Philippines
Posts: 1 cabron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to cabron
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>
<?
}

?>

Reply With Quote
  #2  
Old June 18th, 2003, 11:38 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
The following line (please look closely and compare):
Quote:
if ($submit == "Enter information")
<input type = "submit" name = "update" value = "Update information">

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:
if ($update == "Enter information"
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Last edited by laidbak : June 18th, 2003 at 11:40 AM.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > edit data in PHP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway