Dear all,
I have problem with updating value from database. Here is my code:
<?php
include("../../fckeditor.php") ;
require("db_connect.php");
$selectsql="select * from tbljob where Jobid='$Jobid'";
$selectresult=mysql_query($selectsql);
$selectrow=mysql_fetch_array($selectresult);
?>
<html>
<head>
<title>Job Post</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="../sample.css" rel="stylesheet" type="text/css" />
<link href="style/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<form action="Jobedit.php" method="post" name="JobEdit">
<input type="hidden" name="Jobid" value="<?=$Jobid?>">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
<tr><td width="10%">Job Title</td>
<td width="90%"><input name="Jobtitle" type="text" width="60" value="<?=$selectrow['Jobtitle']?>"></td></tr>
<tr><td>Category</td><td>
<select name="Catid">
<? $catsql="select * from tbljobcat order by Catname asc";
$catresult=mysql_query($catsql);
while($catrow=mysql_fetch_array($catresult)){
if($selectrow['Catid']==$catrow['Catid']){
?>
<option value="<?=$catrow['Catid']?>" selected><?=$catrow['Catname']; ?></option>
<? }else{?>
<option value="<?=$catrow['Catid']?>"><?=$catrow['Catname']; ?></option>
<? } }?>
</select></td></tr>
<tr><td>Company Name</td><td><input type="text" name="Jobcompany" width="60" value="<?=$selectrow['Jobcompany']?>"></td></tr>
<tr><td>Closing Date</td><td> <select name="jday">
<? $dd=substr($selectrow['Jobclosedate'],8,2);
for($a=1;$a<32;$a++){
if($a==($dd)){
?>
<option value="<?=$a?>" selected><?=$a?></option>
<? }else{?>
<option value="<?=$a?>"><?=$a?></option>
<? }}?>
</select> <select name="jmonth">
<?
$mm=substr($selectrow['Jobclosedate'],5,2);
$montharray=array("","January","February","March","April","May","June","July","August","September","October","November","December");
for($b=1;$b<13;$b++){
if($b==($mm)){
?>
<option value="<?=$b?>" selected><?=$montharray[$b]?></option>
<? }else{?>
<option value="<?=$b?>"><?=$montharray[$b]?></option>
<? }}?>
</select> <select name="jyear">
<?
$yy=substr($selectrow['Jobclosedate'],0,4);
for($c=date("Y");$c<2015;$c++){
if($c==($yy)){
?>
<option value="<?=$c?>" selected><?=$c?></option>
<? }else{?>
<option value="<?=$c?>"><?=$c?></option>
<? }}?></select></td></tr>
<tr><td>Location</td>
<td><select name="Locid">
<? $locsql="select * from tbljoblocation order by Locname asc";
$locresult=mysql_query($locsql);
while($locrow=mysql_fetch_array($locresult)){
if($selectrow['Locid']==$locrow['Locid']){
?>
<option value="<?=$locrow['Locid']?>" selected><?=$locrow['Locname']; ?></option>
<? }else{?>
<option value="<?=$locrow['Locid']?>"><?=$locrow['Locname']; ?></option>
<? }}?>
</select></td></tr>
<tr><td> </td><td>
<?php
$Jobdetail=$selectrow['Jobdetail'];
$oFCKeditor = new FCKeditor('FCKeditor1');
$oFCKeditor->Value = $Jobdetail;
$oFCKeditor->Create();?></td></tr>
<tr><td> <td colspan="2"><input type="submit" name="Save" value="Save">
</tr>
</table>
</form>
<?
echo $Jobdetail;
$Jobclosedate=$jyear."-".$jmonth."-".$jday;
if(isset($_POST["Save"])){
$updatesql="UPDATE tbljob SET Jobtitle='$Jobtitle', Jobcompany='$Jobcompany',Jobclosedate='$Jobclosedate', Catid='$Catid', Locid='$Locid', Jobdetail='$Jobdetail' WHERE Jobid='$Jobid'";
echo $updatesql;
$updateresult=mysql_query($updatesql);
}
if($updateresult){
//echo "<meta http-equiv=\"refresh\" content=\"0;URL=Jobpost.php\">";
}
?>
</body>
</html>
I am looking forwards to hearing from you soon.
Kindly regards,
Bunhok
Tue, 09/23/2008 - 06:27
#1