0

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>

3
Contributors
8
Replies
9
Views
9 Years
Discussion Span
Last Post by nav33n
0

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.

Edited by mike_2000_17: Fixed formatting

0

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>

0

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'");

Edited by mike_2000_17: Fixed formatting

0

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.

0

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>

0

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>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.