【php开源代码栏目提醒】:网学会员,鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“BookDetail.php”一文,供大家参考学习!
<?php
include ("./common.php");
include ("./Header.php");
include ("./Footer.php");
session_start();
$filename = "BookDetail.php";
check_security(1);
$tpl = new Template($app_path);
$tpl->load_file("BookDetail.html", "main");
$tpl->load_file($header_filename, "Header");
$tpl->load_file($footer_filename, "Footer");
$tpl->set_var("FileName", $filename);
$sDetailErr = "";
$sOrderErr = "";
$sRatingErr = "";
$sAction = get_param("FormAction");
$sForm = get_param("FormName");
switch ($sForm) {
case "Detail":
Detail_action($sAction);
break;
case "Order":
Order_action($sAction);
break;
case "Rating":
Rating_action($sAction);
break;
}Menu_show();
Footer_show();
Detail_show();
Order_show();
Rating_show();
$tpl->parse("Header", false);
$tpl->parse("Footer", false);
$tpl->pparse("main", false);
//********************************************************************************
function Detail_action($sAction)
{
global $db;
global $tpl;
global $sForm;
global $sDetailErr;
$sParams = "";
$sActionFileName = "ShoppingCart.php";
$sParams = "?";
$sParams .= "item_id=" . tourl(get_param("Trn_item_id"));
$sWhere = "";
$bErr = false;
if($sAction == "cancel")
header("Location: " . $sActionFileName . $sParams);
// Load all form fields into variables
$sSQL = "";
// Create SQL statement
// Execute SQL statement
if(strlen($sDetailErr)) return;
$db->query($sSQL);
header("Location: " . $sActionFileName . $sParams);
}
function Detail_show()
{
global $db;
global $tpl;
global $sAction;
global $sForm;
global $sDetailErr;
$sWhere = "";
$bPK = true;
$flditem_id = "";
$fldname = "";
$fldauthor = "";
$fldcategory_id = "";
$fldprice = "";
$fldimage_url = "";
$fldnotes = "";
$fldproduct_url = "";
if($sDetailErr == "")
{
// Load primary key and form parameters
$flditem_id = get_param("item_id");
$tpl->set_var("Trn_item_id", get_param("item_id"));
$pitem_id = get_param("item_id");
$tpl->set_var("DetailError", "");
}
else
{
// Load primary key, form parameters and form fields
$flditem_id = strip(get_param("item_id"));
$tpl->set_var("Trn_item_id", get_param("Trn_item_id"));
$pitem_id = get_param("PK_item_id");
$tpl->set_var("sDetailErr", $sDetailErr);
$tpl->parse("DetailError", false);
}
if( !strlen($pitem_id)) $bPK = false;
$sWhere .= "item_id=" . tosql($pitem_id, "Number");
$tpl->set_var("PK_item_id", $pitem_id);
$sSQL = "select * from items where " . $sWhere;
if($bPK && !($sAction == "insert" && $sForm == "Detail"))
{
// Execute SQL statement
$db->query($sSQL);
$db->next_record();
$flditem_id = $db->f("item_id");
$fldname = $db->f("name");
$fldauthor = $db->f("author");
$fldcategory_id = $db->f("category_id");
$fldprice = $db->f("price");
$fldimage_url = $db->f("image_url");
$fldnotes = $db->f("notes");
$fldproduct_url = $db->f("product_url");
$tpl->set_var("DetailDelete", "");
$tpl->set_var("DetailUpdate", "");
$tpl->set_var("DetailInsert", "");
}
else
{
if($sDetailErr == "")
{
$flditem_id = tohtml(get_param("item_id"));
}
$tpl->set_var("DetailEdit", "");
$tpl->set_var("DetailInsert", "");
}
$tpl->set_var("DetailCancel", "");
// Set lookup fields
$fldcategory_id = dlookup("categories", "name", "category_id=" . tosql($fldcategory_id, "Number"));
if($sDetailErr == "")
{
$fldimage_url="<img border=0 src=" . $fldimage_url . ">";
$fldproduct_url="Review this book on Amazon.com";
}
// Show form field
$tpl->set_var("item_id", tohtml($flditem_id));
$tpl->set_var("name", tohtml($fldname));
$tpl->set_var("author", tohtml($fldauthor));
$tpl->set_var("category_id", tohtml($fldcategory_id));
$tpl->set_var("price", tohtml($fldprice));
$tpl->set_var("image_url", $fldimage_url);
$tpl->set_var("image_url_URLLink", $db->f("product_url"));
$tpl->set_var("notes", $fldnotes);
$tpl->set_var("product_url", tohtml($fldproduct_url));
$tpl->set_var("product_url_URLLink", $db->f("product_url"));
$tpl->parse("FormDetail", false);
}
function Order_action($sAction)
{
global $db;
global $tpl;
global $sForm;
global $sOrderErr;
$sParams = "";
$sActionFileName = "ShoppingCart.php";
$sWhere = "";
$bErr = false;
if($sAction == "cancel")
header("Location: " . $sActionFileName);
// Load all form fields into variables
$fldUserID = get_session("UserID");
$fldquantity = get_param("quantity");
$fld