Problem with update script. - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > PHP Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-15-2009, 06:47 AM   #1 (permalink)
Junior Member
 
Join Date: May 2009
Location: Hyderabad (India)
Posts: 12
Default Problem with update script.

I am creating a form with insert, retrieve and update. Here insert and retrieve scripts are working good, but the update script is not working. did i made anything wrong in the script. Please guide me.


here are the three php scripts.

JobNotes.php (for retrieve)


<html>
<head>

<style type="text/css">
p.three
{
border-bottom-color:#CCC;
border-bottom-style:solid;
border-width:1px;

}
</style>

<script type="text/javascript">
function open_win()
{
window.open("AddJob.php",'','width=480,height=150, left=750,top=150');
}

</script>
<SCRIPT language="JavaScript">


function editwin()
{
window.open('Edit.php','jav','width=480,height=150 ,left=750,top=150');
}

</SCRIPT>

</head>

<body>

<table width="100%" border="0">
<tr>
<td>Job Notes</td>
<td><input type=button value="AddNew" onClick="open_win()"></td>
</tr>
</table>
<br>
<br>
<?php

mysql_connect('localhost','root','');
@mysql_select_db('taskmanagement') or die( "Unable to select database");

$query="SELECT * FROM addjob ORDER BY id";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();
?>

<?php
$i=0;
while ($i<$num) {
$f1=mysql_result($result,$i,"add_job");
?>
<table width="75%">
<tr>
<td width="81%">
<font face="Arial, Helvetica, sans-serif" style="border-bottom-color:#C03"><p class="three"><?php echo $f1; ?></p>
</font>
</td>
<td width="3%">
<a href="javascript:editwin()"=<?php echo $f1['id']; ?>"><img src="edit.gif" width="16" height="16" hspace="0" vspace="0" border="0"></a>
</td>
</tr>
</table>
<?php
++$i;
}
?>
</body>
</html>


AddJob.php (for insert)

<?php

$hostname = "localhost";
$db_user = "root";
$db_password = "";
$database = "taskmanagement";
$db_table = "addjob";

$db = mysql_connect($hostname, $db_user, $db_password);
mysql_select_db($database,$db);
?>
<html>
<head>
<title>Add Notes</title>
<script type="text/javascript">
function RefreshParentWindow()
{
if (window.opener && !window.opener.closed)
{
window.opener.location.reload();
self.close();
}
}


</script>
</head>
<body OnLoad="document.ad_A.addJob.focus();"">

<?php
if (isset($_REQUEST['Submit'])) {
$sql = "INSERT INTO $db_table(add_job) values ('".mysql_real_escape_string(stripslashes($_REQUES T['addJob']))."')";
if($result = mysql_query($sql ,$db)) {
} else {
echo "ERROR: ".mysql_error();
}
} else {
?>
<form method="post" action="" name="ad_A">
Add Notes:<br>
<textarea name="addJob" cols="50" rows="5" class="add"></textarea>
<input type="submit" name="Submit" value="OK" onClick="RefreshParentWindow()">
</form>
<?php
}
?>
</body>
</html>



Edit.php (for update)

<?php

$hostname = "localhost";
$db_user = "root";
$db_password = "";
$database = "taskmanagement";
$db_table = "addjob";

$db = mysql_connect($hostname, $db_user, $db_password);
mysql_select_db($database,$db);
?>
<html>
<head>
<title>Edit Notes</title>
<script type="text/javascript">
function RefreshParentWindow()
{
if (window.opener && !window.opener.closed)
{
window.opener.location.reload();
self.close();
}
}


</script>
</head>
<body OnLoad="document.ad_E.edit.focus();"">

<?php
$edit=$_POST[edit];
if (isset($_REQUEST['Submit'])) {

$sql = "update addjob set add_job='$edit' where id='$id'";
if($result = mysql_query($sql ,$db)) {
} else {
echo "ERROR: ".mysql_error();
}
} else {
?>
<form method="post" action="" name="ad_E">
Edit Notes:<br>
<textarea name="edit" cols="50" rows="5" class="add"></textarea>
<input type="submit" name="Submit" value="OK" onClick="RefreshParentWindow()">
</form>
<?php
}
?>
</body>
</html>


Thanks.
jyothip is offline   Reply With Quote
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 09:32 AM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting