我有3个php文件。第一个dispatch.php创建一个表单,其中包含下拉选择的员工(必须通过的变量),您必须从中选择并显示带有数据行的dispatch2.php。每行的第一列是一个复选框,它=订单号(必须通过的变量)。第二列dipslays订单号。然后我们有一个额外的列,一个是订单年龄。此列需要订购时间(要传递的变量)并计算年龄(要传递的变量)。因此,您选择员工,相应的复选框,然后单击“提交”。
Dispatch.php和dispatch2.php显示正常。当我点击提交时,我收到一个错误。因此,我没有写入数据库,而是回应了变量,并没有得到任何变量。唯一显示的是非变量OTD。
这里是dispatch_post.php,只有变量的回声。
<?php
echo $orders->fields['order_id'];
echo $orders->fields['date_purchased'];
echo $result->fields['employee_id'];
echo $difference;
echo 'OTD';
?>
&#34; OTD&#34;应该在提交表单时将其写入表中的状态列,因此我没有将其更改为变量。如果我应该让我知道。
这是我制作的第一张表格。所以我很抱歉,如果这很简单,我也没有看到错误。
这是我的档案。 dispatch.php
<?php
/**
* @package admin
* @copyright Copyright 2003-2013 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version GIT: $Id: Author: DrByte Wed Nov 6 21:04:33 2013 -0500 Modified in v1.5.2 $
*/
require('includes/application_top.php');
// unset variable which is sometimes tainted by bad plugins like magneticOne tools
if (isset($module)) unset($module);
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
if (isset($_GET['oID'])) $_GET['oID'] = (int)$_GET['oID'];
include(DIR_WS_CLASSES . 'order.php');
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/dispatch.css">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
// load text file when page loads
$("#div1").load("https://secure3243.hostgator.com/~w57dsjmm/order/ducky/dispatch2.php");
// Then reload it every 5 seconds, for ever ...
setInterval(function(){
$("#div1").load("https://secure3243.hostgator.com/~w57dsjmm/order/ducky/dispatch2.php");
}, 5000);
});
</script>
</head>
<body onLoad="init()">
<!-- header_eof //-->
<!-- body //-->
<!-- body_text //-->
<p><a href="http://order.southshorepizza.net/ducky">ADMIN</A>
Dispatch Screen</p>
<form action="dispatch_post.php" method="post">
<div class="dropdown" valign="center">
<select required name="dropdown">
<option value="Select Driver" selected>Select Driver</option>
<?php
$result = $db->Execute("SELECT * FROM " . TABLE_EMPLOYEES);
while (!$result->EOF) {
echo '<option value="' . $result->fields['employee_id'] . '">' . $result->fields['employee_first'] . '</option>';
$result->MoveNext();
}
?>
</select>
</div>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr class="dataTableHeadingRow">
<td class="dataTableHeadingContent" width="10%" align="center"><?php echo "Dispatch"; ?></td>
<td class="dataTableHeadingContent" width="20%" align="center"><?php echo TABLE_HEADING_ORDERS_ID; ?></td>
<td class="dataTableHeadingContent" width="30%" align="center"><?php echo "Address"; ?></td>
<td class="dataTableHeadingContent" width="20%" align="center"><?php echo "Order Age"; ?></td>
<td class="dataTableHeadingContent" width="20%" align="center"><?php echo TABLE_HEADING_ORDER_TOTAL; ?></td>
</tr>
</table>
<div id="div1">
</div>
<input type="submit">
</form>
</div>
<!-- body_eof //-->
</body>
dispatch2.php
<?php
/**
* @package admin
* @copyright Copyright 2003-2013 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version GIT: $Id: Author: DrByte Wed Nov 6 21:04:33 2013 -0500 Modified in v1.5.2 $
*/
require('includes/application_top.php');
// unset variable which is sometimes tainted by bad plugins like magneticOne tools
if (isset($module)) unset($module);
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
if (isset($_GET['oID'])) $_GET['oID'] = (int)$_GET['oID'];
include(DIR_WS_CLASSES . 'order.php');
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/dispatch.css">
<link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
</head>
<body onLoad="init()">
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<!-- body_text //-->
<tr>
<?php
$new_fields = ", o.delivery_street_address, o.shipping_module_code ";
$orders_query_raw = "select " . $search_distinct . " o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.shipping_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total" .
$new_fields . "
from (" . TABLE_ORDERS_STATUS . " s, " .
TABLE_ORDERS . " o " .
$new_table . ")
left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id and ot.class = 'ot_total') " . "
where (o.orders_status = s.orders_status_id and s.language_id = '" . (int)$_SESSION['languages_id'] . "' and o.shipping_module_code LIKE 'Flat' AND orders_status <> 3) " .
$search . " order by o.orders_id DESC";
//echo '<BR><BR>I SEE C: ' . $orders_query_raw . '<BR><BR>';
//last edit before $orders_query_raw }
// Split Page
// reset page when page is unknown
if (($_GET['page'] == '' or $_GET['page'] <= 1) and $_GET['oID'] != '') {
$check_page = $db->Execute($orders_query_raw);
$check_count=1;
if ($check_page->RecordCount() > '15') {
while (!$check_page->EOF) {
if ($check_page->fields['orders_id'] == $_GET['oID']) {
break;
}
$check_count++;
$check_page->MoveNext();
}
$_GET['page'] = round((($check_count/'15')+(fmod_round($check_count,'15') !=0 ? .5 : 0)),0);
} else {
$_GET['page'] = 1;
}
}
// $orders_query_numrows = '';
$orders_split = new splitPageResults($_GET['page'], '15', $orders_query_raw, $orders_query_numrows);
$orders = $db->Execute($orders_query_raw);
while (!$orders->EOF) {
if ((!isset($_GET['oID']) || (isset($_GET['oID']) && ($_GET['oID'] == $orders->fields['orders_id']))) && !isset($oInfo)) {
$oInfo = new objectInfo($orders->fields);
}
?>
<div id="div1">
<td class="dataTableContent" width="10%" align="center"><input type="checkbox" name="otd" value="$orders->fields['orders_id']" /></td>
<td class="dataTableContent" width="20%" align="center"><?php echo $show_difference . $orders->fields['orders_id']; ?></td>
<td class="dataTableContent" width="30%" align="center"><?php echo $orders->fields['delivery_street_address']; ?></td>
<td class="dataTableContent" width="20%" align="center"><?php
$purchase_time = strtotime ($orders->fields['date_purchased']);
$difference = time () - $purchase_time;
$difference_in_minutes = ceil ($difference / 60); //-Round up to the next minute
echo gmdate("H:i:s", $difference);
?></td>
<td class="dataTableContent" width="20%" align="center"><?php echo strip_tags($orders->fields['order_total']); ?></td></div>
</tr>
<?php
$orders->MoveNext();
}
?>
<tr>
<td class="smallText" valign="top" colspan="2"><?php echo $orders_split->display_count($orders_query_numrows, '15', $_GET['page'], TEXT_DISPLAY_NUMBER_OF_ORDERS); ?></td>
<td class="smallText" align="left"><?php echo $orders_split->display_links($orders_query_numrows, '15', MAX_DISPLAY_PAGE_LINKS, $_GET['page'], zen_get_all_get_params(array('page', 'oID', 'action'))); ?></td>
</tr>
</table>
<!-- body_text_eof //-->
<!-- body_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
最后是dispatch_post.php
<?php
<?php
global $db;
$otd = "otd";
$sql = "insert into " . TABLE_HTA . " (order_id, order_time, employee_id, otd, status) values (:$orders->fields['order_id']:, :$orders->fields['date_purchased']:, :$result->fields['employee_id']:, :$difference:, :'OTD':)";
$sql = $db->bindVars($sql, ':$orders->fields['order_id']:', $valueOne, 'integer');
$sql = $db->bindVars($sql, ':$orders->fields['date_purchased']:', $valueTwo, 'time');
$sql = $db->bindVars($sql, ':$result->fields['employee_id']:', $valueThree, 'integer');
$sql = $db->bindVars($sql, ':$difference:', $valueFour, 'time');
$sql = $db->bindVars($sql, ':$difference:', $valuefive, 'varchar');
$result = $db->Execute($sql);
$newRecordId = $db->Insert_ID();
echo 'The new record added was number: ' . $newRecordId;
?>
非常感谢任何帮助!
答案 0 :(得分:0)
我认为在第一个和第二个中加载html信息可能会让你感到困惑。试试这个:
- 我的评论由nwolybug
注明dispatch.php
<?php
/**
* @package admin
* @copyright Copyright 2003-2013 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version GIT: $Id: Author: DrByte Wed Nov 6 21:04:33 2013 -0500 Modified in v1.5.2 $
*/
require('includes/application_top.php');
// unset variable which is sometimes tainted by bad plugins like magneticOne tools
if (isset($module)) unset($module);
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
if (isset($_GET['oID'])) $_GET['oID'] = (int)$_GET['oID'];
include(DIR_WS_CLASSES . 'order.php');
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/dispatch.css">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
// load text file when page loads
$("#div1").load("https://secure3243.hostgator.com/~w57dsjmm/order/ducky/dispatch2.php");
// Then reload it every 5 seconds, for ever ...
setInterval(function(){
$("#div1").load("https://secure3243.hostgator.com/~w57dsjmm/order/ducky/dispatch2.php");
}, 5000);
});
</script>
</head>
<body onLoad="init()">
<!-- header_eof //-->
<!-- body //-->
<!-- body_text //-->
<p><a href="http://order.southshorepizza.net/ducky">ADMIN</A>
Dispatch Screen</p>
<form action="dispatch_post.php" method="post">
<div class="dropdown" valign="center">
<select required name="dropdown">
<option value="Select Driver" selected>Select Driver</option>
<?php
$result = $db->Execute("SELECT * FROM " . TABLE_EMPLOYEES);
while (!$result->EOF) {
echo '<option value="' . $result->fields['employee_id'] . '">' . $result->fields['employee_first'] . '</option>';
$result->MoveNext();
}
?>
</select>
</div>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr class="dataTableHeadingRow">
<td class="dataTableHeadingContent" width="10%" align="center"><?php echo "Dispatch"; ?></td>
<td class="dataTableHeadingContent" width="20%" align="center"><?php echo TABLE_HEADING_ORDERS_ID; ?></td>
<td class="dataTableHeadingContent" width="30%" align="center"><?php echo "Address"; ?></td>
<td class="dataTableHeadingContent" width="20%" align="center"><?php echo "Order Age"; ?></td>
<td class="dataTableHeadingContent" width="20%" align="center"><?php echo TABLE_HEADING_ORDER_TOTAL; ?></td>
</tr>
</table>
<div id="div1">
</div>
<!--nwolybug added / to end the input -->
<input type="submit" />
</form>
</div>
dispatch2.php
<?php
/**
* @package admin
* @copyright Copyright 2003-2013 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version GIT: $Id: Author: DrByte Wed Nov 6 21:04:33 2013 -0500 Modified in v1.5.2 $
*/
require('includes/application_top.php');
// unset variable which is sometimes tainted by bad plugins like magneticOne tools
if (isset($module)) unset($module);
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
if (isset($_GET['oID'])) $_GET['oID'] = (int)$_GET['oID'];
include(DIR_WS_CLASSES . 'order.php');
?>
<!--nwolybug removed head and body tags, moved formatting to dispatch.php head -->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<!-- body_text //-->
<tr>
<?php
$new_fields = ", o.delivery_street_address, o.shipping_module_code ";
$orders_query_raw = "select " . $search_distinct . " o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.shipping_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total" .
$new_fields . "
from (" . TABLE_ORDERS_STATUS . " s, " .
TABLE_ORDERS . " o " .
$new_table . ")
left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id and ot.class = 'ot_total') " . "
where (o.orders_status = s.orders_status_id and s.language_id = '" . (int)$_SESSION['languages_id'] . "' and o.shipping_module_code LIKE 'Flat' AND orders_status <> 3) " .
$search . " order by o.orders_id DESC";
//echo '<BR><BR>I SEE C: ' . $orders_query_raw . '<BR><BR>';
//last edit before $orders_query_raw }
// Split Page
// reset page when page is unknown
if (($_GET['page'] == '' or $_GET['page'] <= 1) and $_GET['oID'] != '') {
$check_page = $db->Execute($orders_query_raw);
$check_count=1;
if ($check_page->RecordCount() > '15') {
while (!$check_page->EOF) {
if ($check_page->fields['orders_id'] == $_GET['oID']) {
break;
}
$check_count++;
$check_page->MoveNext();
}
$_GET['page'] = round((($check_count/'15')+(fmod_round($check_count,'15') !=0 ? .5 : 0)),0);
} else {
$_GET['page'] = 1;
}
}
// $orders_query_numrows = '';
$orders_split = new splitPageResults($_GET['page'], '15', $orders_query_raw, $orders_query_numrows);
$orders = $db->Execute($orders_query_raw);
while (!$orders->EOF) {
if ((!isset($_GET['oID']) || (isset($_GET['oID']) && ($_GET['oID'] == $orders->fields['orders_id']))) && !isset($oInfo)) {
$oInfo = new objectInfo($orders->fields);
}
?>
<!--nwolybug changed div1 to div2 for naming standards. can't have two divs with same id name -->
<div id="div2">
<td class="dataTableContent" width="10%" align="center"><input type="checkbox" name="otd" value="$orders->fields['orders_id']" /></td>
<td class="dataTableContent" width="20%" align="center"><?php echo $show_difference . $orders->fields['orders_id']; ?></td>
<td class="dataTableContent" width="30%" align="center"><?php echo $orders->fields['delivery_street_address']; ?></td>
<td class="dataTableContent" width="20%" align="center"><?php
$purchase_time = strtotime ($orders->fields['date_purchased']);
$difference = time () - $purchase_time;
$difference_in_minutes = ceil ($difference / 60); //-Round up to the next minute
echo gmdate("H:i:s", $difference);
?></td>
<td class="dataTableContent" width="20%" align="center"><?php echo strip_tags($orders->fields['order_total']); ?></td></div>
</tr>
<?php
$orders->MoveNext();
}
?>
<tr>
<td class="smallText" valign="top" colspan="2"><?php echo $orders_split->display_count($orders_query_numrows, '15', $_GET['page'], TEXT_DISPLAY_NUMBER_OF_ORDERS); ?></td>
<td class="smallText" align="left"><?php echo $orders_split->display_links($orders_query_numrows, '15', MAX_DISPLAY_PAGE_LINKS, $_GET['page'], zen_get_all_get_params(array('page', 'oID', 'action'))); ?></td>
</tr>
</table>
dispatch_post.php
<?php
//nwolybug removed first of two <?php tags
global $db;
$otd = "otd";
$sql = "insert into " . TABLE_HTA . " (order_id, order_time, employee_id, otd, status) values (:$orders->fields['order_id']:, :$orders->fields['date_purchased']:, :$result->fields['employee_id']:, :$difference:, :'OTD':)";
$sql = $db->bindVars($sql, ':$orders->fields['order_id']:', $valueOne, 'integer');
$sql = $db->bindVars($sql, ':$orders->fields['date_purchased']:', $valueTwo, 'time');
$sql = $db->bindVars($sql, ':$result->fields['employee_id']:', $valueThree, 'integer');
$sql = $db->bindVars($sql, ':$difference:', $valueFour, 'time');
$sql = $db->bindVars($sql, ':$difference:', $valuefive, 'varchar');
$result = $db->Execute($sql);
$newRecordId = $db->Insert_ID();
echo 'The new record added was number: ' . $newRecordId;
?>