Hi all i am writing a code to alter the content in multiple select box control. I am using two tables to maintain the order up/down to store the content in the appliction
<?php
session_start();
require("getconnect.php");
if($_GET['action'] == 'test')
{
$a= $_POST['order'];
$b='';
for($i=0;$i<=(sizeof($a)-1);$i++)
{
if($i==(sizeof($a)-1))
{
$b.=$a[$i];
}
else
{ $b.=$a[$i].",";
}
}
$c=explode(",",$b);
$d=sizeof($c);
for($i=0;$i<=$d;$i++)
{
$selqry="select fileid,content from cms where filename='".$c[$i]."'";
$res=mysql_query($selqry,$concsn);
$row=mysql_fetch_row($res);
$fileid=$row[0];
$filecontent=$row[1];
if($i==$d-1)
{
$fileidarr.=$fileid;
$filecontentarr.=$filecontent;
}
else
{
$fileidarr.=$fileid.",";
}
}
$c1=explode(",",$fileidarr);
$selqry="delete from tempcms";
$example=mysql_query($selqry);
for($i=0;$i<=$d-1;$i++)
{
$selqry="insert into tempcms(tempfileid,tempfilename,tempcontent)values(".$i.",'".$c[$i]."','".$filecontent."')";
$res=mysql_query($selqry,$concsn);
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CMS - Add New Page</title>
<script language="JavaScript" src="sort.js"></script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0"><tr>
<td><font color="#FF0000">
<?php if(isset($_GET['module']) && $_GET['module']=='insert'){echo "New Record Added Succesfully";}?>
<?php if(!empty($_SESSION['message'])) echo $_SESSION['message']; $_SESSION['message'] = ''; ?></font>
</td>
</tr></table>
<form method="post" action="insert.php">
<input type="text" name="addpage" value="" />
<input type="submit" name="addpagebutton" value="Add New Page" /></form>
<form name="form1" method="post" action="addnewpage.php?action=test" onSubmit="selectall('order');">
<table border="0" cellpadding="0" cellspacing="0"><tr>
<td>
<select name="order[]" size="16" multiple="multiple" id="order" ondblclick="selectnone(this);">
<?php
$qry="select tempfilename from tempcms order by tempfileid ";
$res=mysql_query($qry,$concsn);
while($row=mysql_fetch_array($res,MYSQL_BOTH))
{
$filename=$row['tempfilename'];
$id=$row['tempfileid'];
$content=$row['tempcontent'];
?>
<option value="<?php echo $filename; ?>"><?php echo $filename;?></option><?php } ?>
</select>
<input type="submit" name="submit" value="Store this structure" />
<input type="button" value="Up" onClick="up('order');" title="Up" style="padding: 0; margin: 0; height: 22px;" /></td>
</tr>
<tr>
<td align="right"> <input type="button" value="Down" onClick="down('order');" title="Down" style="padding: 0; margin: 0; height: 22px;" /></td>
</tr>
<tr>
<td>
<input type="button" name="Backtoindex" value="Back To Index" onclick="javascript:window.location.href('index.php');" />
</td>
</tr>
</table>
</form>
</body>
</html>
look at the above code where in i am clicking storethis structure button the data in the multi select box is loosing.