this is my code here i selected record from db and putted that 2 text box . but i modify the recored to store the db. below the code not working .

<?php

$jtitle=$_GET;
echo $jtitle;
$desc=$_GET;
echo $desc;
$hostname="localhost";
$username="cds";
$password="cds";
$dbid="cdsemplo_job";
$link=mysql_connect($hostname,$username,$password);
mysql_select_db($dbid) or die("not connected");
$result=mysql_query("select * from job where jobtite='$jtitle'");

while($row=mysql_fetch_row($result))
{
$j1=$row[1];
$j2=$row[2];
}


if(isset($_REQUEST))
{
$jtit=$_GET;
echo $jtit;
$desc1=$_GET;
echo $desc1;
mysql_close($link);
mysql_query("update job set jobtite = '$jtitle'");
}
?>
<html>
<body align="center" left="20px" right="20px" bgcolor="#fffff">
<form method="post" action="edit.php">
<center>
<table>
<br>
<tr>
<center><tr>Employement Form</tr></center>
</tr>
<br>
<tr><td> JobTitle </td><td><input type="text" name="jobname" value="<? echo $j1; ?>"></td></tr>
<tr><td> JobDescription </td><td><input type="text" name="jdesc" value="<? echo $j2; ?>"></td></tr>
<center><tr><td> </td><td><input type="submit" name=update value="Update" width="20"></td></tr></center>
<?php


$hostname="localhost";
$username="cds";
$password="cds";
$dbid="cdsemplo_job";
$link=mysql_connect($hostname,$username,$password);
mysql_select_db($dbid) or die("not connected");

mysql_close($link);
?>
</p>
</table>
</center>
</form>
</body>

Recommended Answers

All 8 Replies

mysql_close($link) before the update query.

Btw, You don't have a condition for your update query. This will update all the records in the table and set jobtite to the value that you have entered.

P.S. Next time, please wrap your codes within code-tags.

this full code.........

<?php

$jtitle=$_GET;
echo $jtitle;
$desc=$_GET;
echo $desc;
$hostname="localhost";
$username="cds";
$password="cds";
$dbid="cdsemplo_job";
$link=mysql_connect($hostname,$username,$password);
mysql_select_db($dbid) or die("not connected");
$result=mysql_query("select * from job where jobtite='$jtitle'");

while($row=mysql_fetch_row($result))
{
$j1=$row[1];
$j2=$row[2];
}


if(isset($_REQUEST))
{
$jtit=$_GET;
echo $jtit;
$desc1=$_GET;
echo $desc1;
mysql_close($link);
mysql_query("update job set jobtite = '$jtitle'");
}
?>
<html>
<body align="center" left="20px" right="20px" bgcolor="#fffff">
<form method="post" action="edit.php">
<center>
<table>
<br>
<tr>
<center><tr>Employement Form</tr></center>
</tr>
<br>
<tr><td> JobTitle </td><td><input type="text" name="jobname" value="<? echo $j1; ?>"></td></tr>
<tr><td> JobDescription </td><td><input type="text" name="jdesc" value="<? echo $j2; ?>"></td></tr>
<center><tr><td> </td><td><input type="submit" name=update value="Update" width="20"></td></tr></center>

</p>
</table>
</center>
</form>
</body>

Umm.. I guess you didn't read my post.. Wrap your code in code-tags.. AND

mysql_close($link);
mysql_query("update job set jobtite = '$jtitle'");

BTW: There's nothing wrong with opening a db connection at the top of the script, leaving it open for the rest of your queries and then closing it at the end of your script. It a lot less messy and you are a lot less worried about juggling connections.

it not working ....

<?php

$jtitle=$_GET;
echo $jtitle;
$desc=$_GET;
echo $desc;
$hostname="localhost";
$username="cds";
$password="cds";
$dbid="cdsemplo_job";
$link=mysql_connect($hostname,$username,$password);
mysql_select_db($dbid) or die("not connected");
$result=mysql_query("select * from job where jobtite='$jtitle'");

while($row=mysql_fetch_row($result))
{
$j1=$row[1];
$j2=$row[2];
}

mysql_close($link);

}
?>
<html>
<body align="center" left="20px" right="20px" bgcolor="#fffff">
<form method="post" action="edit.php">
<center>
<table>
<br>
<tr>
<center><tr>Employement Form</tr></center>
</tr>
<br>
<tr><td> JobTitle </td><td><input type="text" name="jobname" value="<? echo $j1; ?>"></td></tr>
<tr><td> JobDescription </td><td><input type="text" name="jdesc" value="<? echo $j2; ?>"></td></tr>
<center><tr><td> </td><td><input type="submit" name=update value="Update" width="20"></td></tr></center>
<?php

$jtitle=$_GET;
echo $jtitle;
$desc=$_GET;
echo $desc;
$hostname="localhost";
$username="cds";
$password="cds";
$dbid="cdsemplo_job";
$link=mysql_connect($hostname,$username,$password);
mysql_select_db($dbid) or die("not connected");
if(isset($_REQUEST))
{
$jtit=$_GET;
echo $jtit;
$desc1=$_GET;
echo $desc1;
mysql_query("update job set jobtite = '$jtitle'");
?>

</p>
</table>
</center>
</form>
</body>
</html>

nevermind.

thank you every one

i got solution below the code


<?php

$jtitle=$_GET;


$hostname="localhost";
$username="cds";
$password="cds";
$dbid="cdsemplo_job";
$link=mysql_connect($hostname,$username,$password);
mysql_select_db($dbid) or die("not connected");
$result=mysql_query("select * from job where jobtite='$jtitle'");

while($row=mysql_fetch_row($result))
{
$j1=$row[1];
$j2=$row[2];
}


if(isset($_REQUEST))
{
$jtitle=$_REQUEST;
$jtitle1=$_REQUEST;
echo $jtitle;
echo "\n";
echo $jtitle1;
$desc=$_REQUEST;
echo $desc;
echo "\n";
mysql_query("update job set jobtite ='$jtitle',jobdesc='$desc' where jobtite='$jtitle1'");
}

mysql_close($link);

?>


<html>
<body align="center" left="20px" right="20px" bgcolor="#fffff">
<form method="post" action="edit.php">
<center>
<table>
<br>
<tr>
<center><tr>Employement Form</tr></center>
</tr>
<br>
<tr><td> JobTitle </td><td><input type="text" name="jobname" value="<? echo $j1; ?>">
<input type="hidden" name="jobname1" value="<? echo $j1; ?>"></td></tr>
<tr><td> JobDescription </td><td><input type="text" name="jdesc" value="<? echo $j2; ?>"></td></tr>
<center><tr><td> </td><td><input type="submit" name=update value="Update" width="20"></td></tr></center>

</p>
</table>
</center>
</form>
</body>
</html>

Phew! Congrats !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.