Hi all
I am facing a problem when i have not totally entered the values in the page and press submit i am loosing values in my select box please correct my code
thanks in advance
<?php
session_start();
include '../getconnect.php';
include("../FCKeditor/fckeditor.php") ;
if(isset($_GET['actionType']) =='E')
{
$_SESSION['code'] = $_GET['start'];
$id=$_GET['id'];
$_SESSION['id'] =$id;
$customer=$_GET['name'];
$getdetails="select testi_id,testi_description,testi_customer,testi_company from blue_testimonials where testi_id='".$_GET['id']."'";
$getquery=mysql_query($getdetails);
$resultquery=mysql_fetch_assoc($getquery);
}
else if(isset($_GET['module']) =='update')
{
$modify="update blue_testimonials set testi_description='".$_POST['FCKeditor1']."'";
$modify.=", testi_company='".$_POST['company']."'";
$modify.=", testi_customer='".$_POST['complementgiven']."'";
$modify.=" where testi_id=".$_GET['id'];
$updateQuery=mysql_query($modify);
$u="update";
$c=$_SESSION['code'];
header("location:managetestimonialpage.php?$u&$c");
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>BLUE MOON BENEFITS GROUP</title>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="../javascript/validation1.js"></script>
<style type="text/css">
<!--
.style1 {font-size: 12px}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body>
<?php if(isset($_GET['actionType'])=='E'){ ?>
<form name="testmonials" method="post" action="testimonials.php?module=update&id=<? echo $resultquery['testi_id'];?>">
<?php } else { ?>
<form name="testmonials" method="post" action='../FCKeditor/_samples/php/sampleposteddatatestimonials.php'>
<?php } ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top"> </td>
</tr>
<tr>
<td align="left" valign="top" class="toptablebackbround"></td>
</tr>
<tr>
<td align="left" valign="top" class="tablebackgroundwhite"><table width="1004" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10%" align="left" valign="top"><table width="219" height="100%" class="tablebackgroundwhite" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top"><?php include("left.php"); ?></td>
<td align="left" valign="top" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<tr>
<td width="192" align="left" > </td>
<td width="27" align="left"> </td>
</tr>
</table></td>
<td align="center" valign="top"><p> <? echo $_SESSION['error_message'];
$company= $_SESSION['company'];?></p>
<table height="228" border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="4" class="ErrMessage"><?php if(!empty($_SESSION['errMessage'])) echo $_SESSION['errMessage']; $_SESSION['errMessage'] ='';?>
</td>
</tr>
<tr>
<td height="99" valign="top"><div align="left"> Testimonial <span class="ErrMessage"><font color="#990000">*</font></span></div></td>
<td valign="top"><div align="center"><strong>: </strong></div></td>
<td width='99%'><!--<textarea name="complement" id="complement" cols="20" rows="6"></textarea>-->
<? $oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = '../FCKeditor/';
if(isset($_GET['actionType'])== 'E')
{
$oFCKeditor->Value =$resultquery['testi_description'];
}
else
{
$oFCKeditor->Value ='';
}
$oFCKeditor->Create()
?></td>
</tr>
<tr>
<td height="46"><div align="left"> Complement Given By <span class="ErrMessage"><font color="#990000">*</font></span> </div></td>
<td><div align="center"><strong>: </strong></div></td>
<td>
<?php
if(isset($_GET['actionType'])=='E')
{
?>
<input name="complementgiven" type="text" id="complementgiven2" value=<?php echo $resultquery['testi_customer'];?>>
<?php
//echo $resultquery['testi_customer'];
}
else
{
?>
<input name="complementgiven" type="text" id="complementgiven2" value=<?php echo $_SESSION['complementgiven']; $_SESSION['complementgiven'] =''; ?> > <?php } ?></td>
</tr>
<tr>
<td height="42"><div align="left"> Company <span class="ErrMessage"><font color="#990000">*</font></span></div></td>
<td><div align="center"><strong>: </strong></div></td>
<td><select name="company" id="select" class="text3" size="1" value=''>
<option value="0" selected> Choose One Company </option>
<?php
$GetCompany="select client_company from blue_clients";
$Getone=mysql_query($GetCompany);
while($GetCompanyName=mysql_fetch_array($Getone))
{
if(isset($_GET['actionType'])=='E')
{
if($GetCompanyName['client_company'] = $resultquery['testi_company'])
{
echo "<option selected value='".$GetCompanyName['client_company']."'>" .$GetCompanyName['client_company']. "</option>";
}
else
{
echo "<option value='".trim($GetCompanyName['client_company'])."'>".$GetCompanyName['client_company']."</option>";
}
}
else
{
//echo $_SESSION['company'];
if(!empty($_SESSION['company']))
{
if($GetCompanyName['client_company']==$_SESSION['company'])
{
print "<option value=".$GetCompanyName['client_company']." selected>" .trim($GetCompanyName['client_company']);
}
else
{
print "<option value=".$GetCompanyName['client_company']." >" .trim($GetCompanyName['client_company']);
}
print "</option>";
}
}
}
/* else
{
print "<option value=".trim($GetCompanyName['client_company']).">" .trim($GetCompanyName['client_company']). "</option>";
}
}*/
?>
</select></td>
</tr>
<tr>
<td height="29" colspan="2" align="left"><span class="style5"><font color="#990000">* Are Mandatory </font></span></td>
<td>
<?php if(isset($_GET['actionType'])=='E') { ?>
<input name="update" type="submit" class="style4" value="Update">
<?php } else { ?>
<input name="submit" class="style4" type="submit" value="submit" onClick="return checkvaluesfromtestmonials();">
<input type="reset" class="style4" name="reset" value="reset"></td>
<?php } ?>
</tr>
</table>
<td width="20" align="left" valign="top"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top" class="bottomtablebackbround"></td>
</tr>
<tr>
<td height="25" align="left" valign="bottom"> </td>
</tr>
<tr>
<td align="left" valign="top"> </td>
</tr>
</table>
</form>
</body>
</html>