<?php
include '../dataConn.php';
include '../manage/getSession.php';
$showtime2=date("YmdHis");
$msg = $_REQUEST['msg'];//add or edit
$showtime=date("Y-m-d");
session_start();
$showtime3='';
if(isset($_SESSION['showTime'])){
$showtime3 = $_SESSION['showTime'];
//echo $showtime3;
}
if($_POST){
$id = $_REQUEST['id'];//ID
$view_id=$_REQUEST['view_id'];//景点id
$view_nm=$_REQUEST['view_nm'];//景点name
$view_addr=$_REQUEST['view_addr'];//景点地址
$view_summary=$_REQUEST['view_summary'];//景点简介
$view_introduce=$_REQUEST['view_introduce'];//景点介绍
$view_continent=$_REQUEST['view_continent'];//所属洲
$view_country=$_REQUEST['view_country'];//所属国家
$view_province=$_REQUEST['view_province'];//所属省
$view_city=$_REQUEST['view_city'];//所属城市
$view_long=$_REQUEST['view_long'];//景点经度
$view_lat=$_REQUEST['view_lat'];//维度
$view_label=$_REQUEST['view_label'];//景点标签
$recommend_yn=$_REQUEST['recommend_yn'];//是否推荐
$collect_num=$_REQUEST['collect_num'];//被收藏数量
$pic_explain=$_REQUEST['pic_explain'];//图片说明文字
$pic_desc=$_REQUEST['pic_desc'];//图片备注
if(empty($view_id))//景点id不许为空
{
echo('<script type="text/javascript">alert("景点不为空!");window.location.href="edit_lvView.php";</script>');
}
if($msg == 'add'){//新增
if(empty($showtime3))
{
echo("<script type='text/javascript'>alert('请先上传图片!');</script>");
}else
{
$str = "insert into lv_view_spot(view_id,view_nm,view_addr,view_summary,view_introduce,view_continent,view_country,view_province,view_city,view_long,view_lat,view_label,recommend_yn,collect_num,CREATE_DT,CREATE_UID,CREATE_UNAME)
values ('$view_id','$view_nm','$view_addr','$view_summary','$view_introduce','$view_continent','$view_country','$view_province','$view_city','$view_long','$view_lat','$view_label','$recommend_yn','$collect_num','$showtime','$sessionuname','$sessionname')";
$result = mysql_query($str,$conn);
$id2 = mysql_insert_id();
//echo $id2;
if($result){
echo("<script type='text/javascript'>alert('添加成功!');</script>");
}
//循环插入景点图片
for($i=1;$i<=3;$i++)
{
$pic_id=$showtime3.$i.".png";
$pic_url="./upload/".$pic_id;
$str1 = "insert into lv_view_picture(view_id,pic_type,pic_nm,pic_url,pic_explain,pic_desc,CREATE_DT,CREATE_UID,CREATE_UNAME)
values ('$id2','1','$pic_id','$pic_url','$pic_explain','$pic_desc','$showtime','$sessionid','$sessionuname')";
$result2 = mysql_query($str1,$conn);
}
}
//header("Location: ../index.php");
}
if($msg == 'edit'){
$sql = "update lv_view_spot set view_id='$view_id', view_nm='$view_nm', view_addr='$view_addr', view_summary='$view_summary' ,view_introduce='$view_introduce' ,view_long='$view_long' ,view_lat='$view_lat', view_label='$view_label',recommend_yn='$recommend_yn' ,collect_num='$collect_num', MODIFY_DT='$showtime', MODIFY_UID='$sessionid', MODIFY_UNAME='$sessionuname' where id='$id'";
$result = mysql_query($sql,$conn);
$result12 = mysql_query("select pic_url from lv_view_picture where view_id = '$id'",$conn);
while($row = mysql_fetch_row($result12)){
$array[] = $row;
}
if(empty($showtime3))
{
echo("<script type='text/javascript'>alert('请先上传图片!');</script>");
}else
{
for($i=0;$i<count($array);$i++)
{
unlink($array[$i][0]); // 删除图片成功执行的
}
$result = mysql_query("delete from lv_view_picture where view_id = '$id'",$conn);
//循环插入景点图片
for($i=1;$i<=3;$i++)
{
$pic_id=$showtime3.$i.".png";
$pic_url="./upload/".$pic_id;
$str1 = "insert into lv_view_picture(view_id,pic_type,pic_nm,pic_url,pic_explain,pic_desc,CREATE_DT,CREATE_UID,CREATE_UNAME)
values ('$id','1','$pic_id','$pic_url','$pic_explain','$pic_desc','$showtime','$sessionid','$sessionuname')";
$result2 = mysql_query($str1,$conn);
}
}
// unlink("./upload/2.png"); 删除图片成功执行的
if($result){
echo("<script type='text/javascript'>alert('修改成功!');window.location.href='list_daohang.php';</script>");
}
header("Location:list_lvView.php");
}
}
if($_GET){
if(isset($_GET["msg"]))
{
$msg = $_GET["msg"];
}
if($msg == "edit"){
$id = $_REQUEST['id'];
$result = mysql_query("select * from lv_view_spot where id = '$id'",$conn);
while($row = mysql_fetch_row($result)){
$array[] = $row;
}
}
}
?>
<!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=UTF-8" />
<title>列表</title>
<script type="text/javascript" src=\'#\'" /ui3/libs/js/jquery.js"></script>
<script type="text/javascript" src=\'#\'" /ui3/libs/js/framework.js"></script>
<link href="../ui3/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" id="skin" prePath="../ui3/"/>
<link rel="stylesheet" type="text/css" id="customSkin"/>
<script type="text/javascript" src=\'#\'" /tool/mydate/jquery-calendar.js"></script>
<link rel="stylesheet" type="text/css" href="../tool/mydate/jquery-calendar.css" />
<!-- 日期选择框end-->
<script>
var xmlhttp=null;
function is_ajax(){
try{
xmlhttp=new XMLHttpRequest();
}catch(e){
try{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
alert('浏览器不支持ajax!');
return false;
}
}
}
}
</script>
<style>
body,select
{
font-size:9pt;
font-family:Verdana;
}
a
{
color:red;
text-decoration:none;
}
a:hover{
text-decoration:underline;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
</SCRIPT>
<SCRIPT LANGUAGE = JavaScript>
function save(){
//var title = $("#title").val();
//var url = $("#url").val();
//var remark = $("#remark").val();
//var status = $("#status").val();
//if(title == ""){alert("请先输入标题!");return;}
document.getElementById("myform").submit();
}
function uploadevent(status){
//alert(status);
status += '';
switch(status){
case '1':
break;
break;
case '-1':
window.location.reload();
break;
default:
window.location.reload();
}
}
//洲变动
function sel_change(value){
is_ajax();
// alert(value);
var url="show_country.php?con_id="+value;
xmlhttp.open('GET',url,true);
xmlhttp.onreadystatechange=show_country;
xmlhttp.send(null);
/**
$.ajax({
url: "show_country.php",
type:'POST',
complete :function(){}, //�求完回�{的函�担��o�成功�c失�《���{用,在success後
dataType: 'json', //��把回�鞯淖址�串自�愚D�Q��json�ο螅�
data: {con_id: value},
success: function(response) {
alert(response.id+response.nm);
$("#yname").attr("value",response.yname);
$('#zubie').val(response.zubie);
$('#zhiwu').val(response.zhiwu);
alert('添加成功!');
}
}); **/
}
function show_country(){
if(xmlhttp.readyState==4){
if(xmlhttp.status==200){
var text=xmlhttp.responseText;
//alert(text);
var json=eval("("+text+")");
// alert(json.length);
var selObj=document.getElementById("view_country");
selObj.length=0;
var option=new Option('请选择','');
selObj.options.add(option);
// alert(json.length);
for( var i=0;i<json.length;i++){
//alert(json[i][1]+json[i][3]);
selObj.options.add(new Option(''+json[i][3]+'',''+json[i][1]+''));
}
$("#view_country").render();
}
}
}
//国家变动
function cou_change(value){
is_ajax();
// alert(value);
var url="show_provice.php?cou_id="+value;
xmlhttp.open('GET',url,true);
xmlhttp.onreadystatechange=show_provice;
xmlhttp.send(null);
/**
$.ajax({
url: "show_country.php",
type:'POST',
complete :function(){}, //�求完回�{的函�担��o�成功�c失�《���{用,在success後
dataType: 'json', //��把回�鞯淖址�串自�愚D�Q��json�ο螅�
data: {con_id: value},
success: function(response) {
alert(response.id+response.nm);
$("#yname").attr("value",response.yname);
$('#zubie').val(response.zubie);
$('#zhiwu').val(response.zhiwu);
alert('添加成功!');
}
}); **/
}
//显示省
function show_provice(){
if(xmlhttp.readyState==4){
if(xmlhttp.status==200){
var text=xmlhttp.responseText;
//alert(text);
var json=eval("("+text+")");
//alert(json.length);
var selObj=document.getElementById("view_province");
selObj.length=0;
var option=new Option('请选择','');
selObj.options.add(option);
// alert(json.length);
for( var i=0;i<json.length;i++){
//alert(json[i][1]+json[i][3]);
selObj.options.add(new Option(''+json[i][4]+'',''+json[i][1]+''));
}
$("#view_province").render();
}
}
}
//省变动
function pro_change(value){
is_ajax();
// alert(value);
var url="show_city.php?cou_id="+value;
xmlhttp.open('GET',url,true);
xmlhttp.onreadystatechange=show_city;
xmlhttp.send(null);
/**
$.ajax({
url: "show_country.php",
type:'POST',
complete :function(){}, //�求完回�{的函�担��o�成功�c失�《���{用,在success後
dataType: 'json', //��把回�鞯淖址�串自�愚D�Q��json�ο螅�
data: {con_id: value},
success: function(response) {
alert(response.id+response.nm);
$("#yname").attr("value",response.yname);
$('#zubie').val(response.zubie);
$('#zhiwu').val(response.zhiwu);
alert('添加成功!');
}
}); **/
}
//显示市
function show_city(){
if(xmlhttp.readyState==4){
if(xmlhttp.status==200){
var text=xmlhttp.responseText;
//alert(text);
var json=eval("("+text+")");
//alert(json.length);
var selObj=document.getElementById("view_city");
selObj.length=0;
var option=new Option('请选择','');
selObj.options.add(option);
// alert(json.length);
for( var i=0;i<json.length;i++){
//alert(json[i][1]+json[i][3]);
selObj.options.add(new Option(''+json[i][5]+'',''+json[i][1]+''));
}
$("#view_city").render();
}
}
}
//查找经纬度
function fixedLocation(){
var result=showModalDialog("googlemap.php","","dialogWidth=800px;dialogHeight=600px;");
var latlng=result.split("_");
$("#view_long").val(latlng[0]);
$("#view_lat").val(latlng[1]);
}
<?php if($array[0][6]!="") {?>
$(document).ready(function(){
alert();
var value=("<?php echo $array[0][6] ?>");
$("#view_continent").val("<?php echo $array[0][6] ?>");
$("#view_continent").render();
sel_change(value)
});
<?php }?>
//-->
</SCRIPT>
</head>
<body >
<div class="box2" panelTitle="导航管理" roller="false" style="overflow: scroll; height:450px;">
<form action="" method="post" name="myform" id="myform">
<input name="id" id="id" type="hidden" value="<?php echo $array[0][0] ?>"/>
<input name="msg" id="msg" type="hidden" value="<?php echo $msg; ?>"/>
<table border="1" width="100%">
<tr >
<td align="center" width="50%" >
<table border="0" height="241" width="100%" >
<tr height="30">
<td height="43" align="right" nowarp >景点编号:</font></td>
<td align="left"><input name="view_id" id="view_id" type="text" value="<?php echo $array[0][2] ?>" ><font color="#FF0000">*</font></td>
</tr>
<tr height="30">
<td height="44" align="right">景点名称:</font></td>
<td align="left"><input style="width:90%" name="view_nm" id="view_nm" type="text" value="<?php echo $array[0][1] ?>" ></td>
</tr>
<tr height="30">
<td height="39" align="right">景点地址:</font></td>
<td align="left"><input style="width:90%" name="view_addr" id="view_addr" type="text" value="<?php echo $array[0][3] ?>" /></td>
</tr>
<tr height="30">
<td height="39" align="right">景点介绍:</font></td>
<td align="left"><input style="width:90%" name="view_introduce" id="view_introduce" type="text" value="<?php echo $array[0][5] ?>" /></td>
</tr>
<tr height="30">
<td height="39" align="right">景点简介:</td>
<td align="left"><input name="view_summary" id="view_summary" type="text" value="<?php echo $array[0][4] ?>" /></td>
</tr>
<tr height="30">
<td height="39" align="right">所属洲:</td>
<td align="left"><label for="view_continent"></label>
<select name="view_continent" size="1" class="lineHeight150" id="view_continent"
onchange="sel_change(this.value)">
<option>请选择大洲</option>
<?php
//查询大洲信息
$resultZ = mysql_query("select * from lv_continent ",$conn);
mysql_query("set names utf8");
while($res = mysql_fetch_assoc($resultZ)){
?>
<option value="<?php echo $res['continent_id'] ;?>"><?php echo $res['continent_nm']; ?></option>
<?php }?>
</select></td>
</tr>
<tr height="30">
<td height="39" align="right">所属国家:</td>
<td align="left">
<select name="view_country" id="view_country" onchange="cou_change(this.value)">
<option>国家</option>
</select></td>
</tr>
<tr height="30">
<td height="39" align="right">所属省/州:</td>
<td align="left">
<select id="view_province" name="view_province" onchange="pro_change(this.value)"><option>省份</option>
</select>
</td>
</tr>
<tr height="30">
<td height="39" align="right">所属市:</td>
<td align="left">
<select id="view_city" name="view_city"><option>地级市</option></select>
</td>
</tr>
<tr height="30" style="display:none">
<td height="39" align="right">县:</td>
<td align="left"><select id="s3"><option>市、县级市、县</option></select></td>
</tr>
<tr>
<td colspan="2"><input type="button" value="地图检索" align="right" color="red">点击搜索可以获取地理位置的经纬度</font></td>
</tr>
<tr height="30" >
<td height="39" align="right">景点所在经度:</td>
<td align="left"><label for="view_long"></label>
<input type="text" name="view_long" id="view_long" value="<?php echo $array[0][10] ?>" /></td>
</tr>
<tr height="30" >
<td height="39" align="right">景点所在纬度:</td>
<td align="left"><label for="view_lat"></label>
<input type="text" name="view_lat" id="view_lat" value="<?php echo $array[0][11] ?>" /></td>
</tr>
<tr height="30">
<td height="44" align="right">景点标签:</font></td>
<td align="left"><input style="width:90%;" name="view_label" id="view_label" type="text" value="<?php echo $array[0][12] ?>" ></td>
</tr>
<tr height="30">
<td height="39" align="right">是否特色推荐:</td>
<td align="left"><input type="radio" name="recommend_yn" id="recommend_yn" value="是"
<?php if ($array[0][13]=="是") echo "checked=\"checked\""; ?> checked/>
<label for="recommend_yn">是
<input type="radio" name="recommend_yn" id="recommend_yn2" value="否" <?php if ($array[0][13]=="否") echo "checked=\"checked\""; ?> />
否</label></td>
</tr>
<tr height="30">
<td height="39" align="right">收藏数量:</font></td>
<td align="left">
<input type="text" name="collect_num" id="collect_num" value="<?php echo $array[0][14] ?>" />
</td>
</tr>
<tr height="30">
<td align="right"></font></td>
<td align="left">
<input type="button" name="baocun" value="提交" onclick="save();">
<input type="button" name="baocun" value="返回" onclick="history.go(-1);">
</td>
</tr>
</table>
</td>
<td width="50%">
<h1>图片上传</h1>
<!--放入项目中 start -->
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
WIDTH="650" HEIGHT="450" id="myMovieName">
<PARAM NAME=movie VALUE="avatar.swf">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<param name="flashvars" value="imgUrl=./default.jpg&uploadUrl=./upfile.php?nm=<?php echo $showtime2; ?>&uploadSrc=false" />
<EMBED src=\'#\'" quality=high bgcolor=#FFFFFF WIDTH="650" HEIGHT="450" wmode="transparent" flashVars="imgUrl=./default.jpg&uploadUrl=./upfile.php?nm=<?php echo $showtime2; ?>&uploadSrc=false"
NAME="myMovieName" ALIGN="" TYPE="application/x-shockwave-flash" allowScriptAccess="always"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>
<!--放入项目中 end -->
<br />
图片说明文字:<input type="text" name="pic_explain" />
备注:<input type="text" name="pic_desc" />
</td>
</tr>
</table>
</form>
</div>
<div style="height:35px;">
<div class="clear"></div>
</div>
</body>
</html>
本文出自 “一切皆有可能” 博客,谢绝转载!