大家早上好:
如果有人能给我一些关于我正在开发的基于网络的文件规划系统的建议,我将不胜感激。我在一家政府机构的一个部门工作,负责记录管理。我们与该机构的其他部门合作,帮助他们制定文件计划,使其符合有关记录保留的联邦法律法规。我们目前正在使用每个部门下载的Access数据库来输入各种文件夹的名称,然后分配某些其他特征。我的部门希望从Access平台转移到一个合适的基于web的应用程序。我有在MySQL、SQL Server等中构建SQL数据库以进行分析的丰富背景。而且,在过去的几年里,我偶尔会使用PHP,所以我不是一个新手,但我也不是专家,所以我可以帮助解决一些代码的故障。
以下是该系统需要如何工作的概述。用户将在文本框中输入文件夹名称,然后通过从一系列下拉框中进行选择,为文件夹指定其他特征。它们是:
介质类型:纸张、dvd/cd、软盘、其他分类类型:非保密、机密、机密、绝密处置:与子系列相同
最后三个很容易。我成功地编写了while和mysql_fetch_arrays,以便从数据库中的表中检索它们,并显示为下拉选择。
现在是第一个棘手的部分。用户必须分配一个组、文件系列和子文件系列,其中组是最高级别,文件系列是下一级别,子文件系列是最精细的。这看起来像Group 100 Admin Files--->File Series 101 Personnel Files--->Sub File Series 101-01 Supervisor Review Files。在子文件系列表中,有715个选项。当前的Access数据库要求用户点击所有715个排列来找到相关的子文件系列,这是Access数据库最大的抱怨。因此,为了在新系统中帮助用户,我想使用一系列相关的下拉菜单,这样用户就可以从最高级别开始进行选择,然后只用该组的文件系列填充中间级别,然后用只与以前的文件系列选择相关联的子文件系列填充底部级别。我也能让它发挥作用。
但这是我的两个问题。我需要能够在同一页面上显示用户的选择,就像购物车一样,用户可以在购物车中编辑或删除文件夹名称和基本选择。在我的index.php脚本中,我有一个include语句,它本来打算这样做,但它不起作用。当用户单击提交时,它会在一个新页面中显示用户输入,我真的需要它与表单显示在同一页面上……最好显示在表单的右侧。我的第二个问题是,当用户单击"提交",浏览器转到新页面显示用户输入时,它将正确显示除子文件系列之外的所有用户输入/选择。它不显示子文件系列,而只显示中级选项的副本:文件系列。以下是的外观
文件名:Folder1介质类型:dvd/cd分类类型:绝密处置类型:与子系列相同组名称:100个管理文件档案系列:101个人档案子文件系列:101-01主管审查文件
这是有缺陷的输出
文件名:Folder1介质类型:dvd/cd分类类型:绝密处置类型:与子系列相同组名:100文件系列:101子文件系列:101
这是我的密码。请原谅任何小的印刷错误。我不得不手动转录这个代码,因为它在不同的服务器上。如果有一些小错误,它们可能不会导致我需要修复的问题。感谢大家给我的建议。我知道我的代码对于这个网站上所有的老开发者来说可能有点粗糙和业余,所以对我温和一点。:)
index.php
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<head>
<title>File Entry</title>
<script type = "text/javascript" src="jquery-1.5.2.min.js"></script>
<style type ="text/css">
body {
font-family:arial;
color:#010DF;
}
form select{
padding:5px;
border:1px solid:#aaa;
border-radius:4px;
width:400px;
}
form label{
font-size:12px;
font-weight:bold;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
load_options('','Group');
});
function load_options(id,index){
$("#loading").show();
if(index=="FileSeries"){
$("#SubFileSeries").html('<option value="">Select SubFileSeries</option>');
}
$.ajax({
url: "ajax.php?index=+index+"&id="+id,
complete: function(){$("#loading").hide():},
success: function(data) {
$("#"+index).html(data);
}
})
}
</script>
</head>
<body>
<div style="width:2000px; margin: auto; padding-top:100px;">
<form action="SendUserSelectionsToArray.php" method="post">
<p>Folder Name: <input type = "text" name = "Foldername1"/></p>
<p><label>Select Media type</label>
<?php
mysql_connect('localhost','fakename1','fakepassword1') or die("Connection Failed");
mysql_select_db('csc') or die("Connection Failed");
$query = "SELECT media_type FROM Media";
$result = mysql_query($query);
?>
<select name="selectMediaType1">
<?php
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
?>
<option value = "<?php echo $line['media_type'];?>"> <?php echo $line['media_type'];?></option>
<?php
}
?>
</select>
</p>
<p><label>Select Media type</label>
<?php
mysql_connect('localhost','fakename1','fakepassword1') or die("Connection Failed");
mysql_select_db('csc') or die("Connection Failed");
$query = "SELECT classification_type FROM Classification";
$result = mysql_query($query);
?>
<select name="classificationType1">
<?php
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
?>
<option value = "<?php echo $line['classification_type'];?>"> <?php echo $line['classification_type'];?></option>
<?php
}
?>
</select>
</p>
<p><label>Select Media type</label>
<?php
mysql_connect('localhost','fakename1','fakepassword1') or die("Connection Failed");
mysql_select_db('csc') or die("Connection Failed");
$query = "SELECT dispostion_type FROM disposition";
$result = mysql_query($query);
?>
<select name="dispositionType1">
<?php
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
?>
<option value = "<?php echo $line['disposition_type'];?>"> <?php echo $line['disposition_type'];?></option>
<?php
}
?>
</select>
</p>
<p><label>Select Group</label></p>
<p><select name="Group1" id="Group" onchange="load_options(this.value, 'FileSeries');"><option value="">Select Group</option>
</select></p>
<p><label>Select File Series</label></p>
<p><select name="FileSeries1" id="FileSeries" onchange="load_options(this.value, 'SubFileSeries');"><option value="">Select File Series</option>
</select></p>
<p><label>Select Sub File Series</label></p>
<p><select name="SubFileSeries1" id="SubFileSeries"><option value="">Select Group</option>
</select></p>
<img src="loader.gif" id="loading" align="absmiddle" style="display:none'"/>
<p>input type = "submit" id="sendtoarray" value="Submit and Enter Another Folder/></p>
</form>
</div>
</body>
</html>
<?php
include('SendUserSelectionsToArray.php');
?>
ajax.php
<?php
class AJAX {
private $database = NULL;
private $_query = NULL;
private $_fields = array();
private $_index = NULL;
const DB_HOST = 'localhost';
const DB_USER = 'fakeuser1';
const DB_PASSWORD = 'fakepassword1';
const DB_NAME = 'csc';
public function __construct() {
$this -> db_connect();
//initiate database connection
$this->process_data();
}
//Connect to database
private function db_connect(){
$this->database = mysql_connect(self::DB_HOST, self::DB_USER, self::DB_PASSWORD);
if($this->database) {
$db = mysql_select_db(self::DB_NAME, $this-> database);
} else {
echo mysql_error();die;
}
}
private function process_data(){
$this->_index=($_REQUEST['index'])?$_REQUEST['index']:NULL;
$id = f($_REQUEST['id'])?$_REQUEST['id']:NULL;
switch($this->_index) {
case 'Group':
$this->_query = "SELECT * FROM groups";
$this->_fields = array('id,'group_display_title');
break;
case 'FileSeries':
$this->_query = "SELECT * FROM file_series WHERE group_id=$id";
$this->_fields = array('file_series_id','file_series_name');
break;
case 'SubFileSeries':
$this->_query = "SELECT * FROM sub_file_series WHERE file_series_id=$id";
$this->_fields = "array('file_series_id','sub_file_series_name');
break;
default: break;
}
$this->show_result();
}
public function show_result() {
echo '<option value="">Select'.$this->_index.'</option>";
$query = mysql_query($this->_query);
while($result = mysql_fetch_array($query)){
$entity_id = $result[$this->fields[0]];
$enity_name = $result[$this->_fields[1]];
echo "<option value='$entity_id'>$enity_name</option>";
}
}
}
$obj = new AJAX;
?>
senduserselectionstoarray.php
<html>
<h1>User Inputs</h1>
<?php
$userselection = array(
'Foldername1' => $_POST['Foldername1'],
'selectMediaType1' => $_POST['selectMediaType1'],
'selectClassificationType1' => $_POST['Foldername1'],
'selectDispositionType1' => $_POST['selectClassificationType1'],
'Group1' => $_POST['Group1'],
'FileSeries1' => $_POST['FileSeries1'],
'SubFileSeries1' => $_POST['SubFileSeries1'],
foreach($userselection1 as $userSelectionArrayDisplay1) {
echo "$userSelectionArrayDisplay1<br />";
}
?>
</html>
如果不希望数据显示在新页面上,可以使用输入框作为按钮,并调用javascript函数在下拉列表右侧的div中显示数据。
<input type="button" value="Submit" onclick="yourFunction()">
当您使用类型为"submit"的输入框时,默认情况下会呈现一个新页面。要让javascript函数将数据显示在右侧,它看起来像这样:
function yourFunction() {
//#tableWrapper is the id of the div that you insert the table with the data into
var displayData = document.getElementById("tableWrapper");
displayData.innerHTML = "<table><tr><td>...."; //Put the data here
}
至于下拉列表问题。您可以在有三个下拉菜单Group、FileSeries和SubFileSeries的情况下执行某些操作。您可以禁用最后两个,当选择组时,您可以用正确的数据填充FileSeries下拉列表,依此类推。阅读此问题以获得一个好的示例:通过从下拉列表中选择,启用另一个下拉
希望这能有所帮助。