查看: 5850|回复: 1
打印 上一主题 下一主题

PHP内容修改选择列表输出为指定选项

[复制链接]
跳转到指定楼层
1#
发表于 2007-9-30 15:28:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
台州网址导航
<?php
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//File:     addlink.php
//Author:   TZNKTG
//Purpose:  This page is add all information of site link  
///////////////////////////////////////////////////////////////////////////////////////////////////////////

session_start();
require("include/dbfun.php");
require("include/common_var.php");

$pageid = $_SESSION['page'];

if(empty($pageid))
{
        $par="";
}
else
{
        $par="?page=".$pageid;       
}

$id = $_GET['id'];

?>

<html>
<head><title><? echo $logotitle ?>-更新友情链接信息</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<link href="css/15hr.css" type="text/css" rel="stylesheet">
<script language="javascript" src="include/per_jslib.js"></script>
<script language="javascript">
<!--
function check()
{
        if(document.modify.sname.value=="")
        {
                        alert("请您输入网站名称!");
                        document.modify.sname.focus();
                        return false;
        }       
        else if(document.modify.surl.value=="")
        {
                        alert("请您输入网站地址!");
                        document.modify.surl.focus();
                        return false;
        }       
        else
        {
                   return true;
        }
}
-->
</script>

</head>
<body>
<?php
if(!$_POST['modify'])
{
?>
<table width="755" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr valign="top">
                <td width="186" valign="top" background="images/middle.gif">
                        <?php
                        //左边菜单栏//
                        require("left.php");
                        ?>               
                </td>
                <td width="15"></td>
                <td rowspan="2" valign="top">
                        <table cellspacing=0 cellpadding=0 width="100%" align="center" border=0>
                          <tbody>
                                <tr>
                                        <td width="5"><img src="images/main_top_left.gif" width="5" height="5" border="0"></td>
                                        <td width="100%" background="images/main_top_center.gif" height="5"></td>
                                        <td width="5"><img  src="images/main_top_right.gif" width="5" height="5" border="0"></td>
                           </tr>
                          </tbody>
                        </table>
                        <table class="main_bg" cellspacing="0" cellpadding="0" width="100%" border="0" align="center">
                          <tbody>
                                  <tr height="5"><td></td></tr>
                                  <tr valign="top">
                                        <td> <img src="images/link_arrow.gif"> 服务器当前时间: <? echo $nowdt ?>  
                                          <br><br></td>
                                  </tr>
                                  <?php
                                        $select_logoinfo_sql="select id,hrsite,sitename,siteurl,siteshow from ".$slinfo_table." where id=".$id;
                                        $db->execute($select_logoinfo_sql);
                                        while($slinfo=$db->reader())
                                        {
                                                $id = $slinfo['id'];
                                                //$hrsite = $slinfo['hrsite'];
                                                $sname = $slinfo['sitename'];
                                                $surl = $slinfo['siteurl'];
                                                $sshow = $slinfo['siteshow'];
                                                //echo $hrsite;
                                  ?>
                                  <tr>
                                        <td>                                    
                                          <form action="<? $PHP_SELF ?>" method="post" name="modify" onSubmit="return check()">
                                                <table cellspacing=0 cellpadding=0 width="95%" align="center" border=0>
                                                        <tbody>
                                                                <tr bgcolor="#EEEEEE"><td height="30" align="center" colspan="4">修改<font color="#FF0000">【<? echo $sname ?>】</font>的友情链接信息</td>
                                                                </tr>
                                                        <tr bgcolor="#FFFFFF">
                                                                        <td height="30" width="15%" align="center">人才站点:</td>
                                                                        <td height="30" width="85%" align="left">
                                                                        <select id="hrsite" name="hrsite">
                                                                        <?php hrsitefun() ?>
                                                                        </select>
                                                            </td>
                                                                </tr>
                                                                <tr bgcolor="#EEEEEE">
                                                                        <td height="30" width="15%" align="center">网站名称:</td>
                                                                    <td height="30" width="15%" align="left"><input type="text" id="sitename" name="sname" size="30" value="<? echo $sname ?>"></td>               
                                                            </tr>                                                         
                                                                <tr bgcolor="#FFFFFF">
                                                                        <td height="30" width="15%" align="center">网站地址:</td>
                                                                        <td height="30" width="85%" align="left"><input type="text" id="siteurl" name="surl" size="40" value="<? echo $surl ?>"></td>
                                                                </tr>                                               
                                                                <tr bgcolor="#EEEEEE">
                                                                        <td height="30" width="15%" align="center">网站说明:</td>
                                                                        <td height="30" width="85%" align="left" >
                                                                        <textarea name="sshow" rows="7" cols="55"><? echo $sshow ?></textarea>
                                                                        </td>
                                                                </tr>                                               
                                                                <tr bgcolor="#FFFFFF">
                                                                        <td height="30" align="center" colspan="4"><input type="submit" name="modify" value=" 修 改 " >  <input type="button" name="back" value=" 返 回 " onclick="history.back()"></td>
                                                                </tr>
                                                                <script language="javascript">               
                                                                //人才站点中文名称
                                                                js_set_sel(document.modify.hrsite,'<? echo $slinfo[hrsite]; ?>');                                       
                                                            </script>               
                                                                                                               
                                                        </tbody>
                                                </table>
                                          </form>
                                         </td>
                                  </tr>
                                        <? } ?>                          </tbody>
                        </table>
                        <table cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
                                <tbody>
                                        <tr>
                                                <td width="5"><img src="images/main_bot_left.gif" width="5" height="5" border="0"></td>
                                                <td width="100%" background="images/main_bot_center.gif" height=5></td>
                                                <td width="5"><img src="images/main_bot_right.gif" width="5" height="5" border="0"></td>
                                        </tr>
                                </tbody>
                        </table>
           </td>
  </tr>
  <tr>
        <td valign="bottom" background="images/middle.gif"><img height="5" src="images/bottom.gif" width="190"></td>
  </tr>
</table>
<?php
}else
{
    $datelog = date("Y-m-d H:i:s"); //日期时间日志;
        $hrsite = htmlspecialchars($_POST['hrsite']);
        $sname = htmlspecialchars($_POST['sname']);
        $surl = htmlspecialchars($_POST['surl']);
        $sshow = htmlspecialchars($_POST['sshow']);

        $update_slinfo_sql = "update ".$slinfo_table." set hrsite='".$hrsite."',sitename='".$sname."',siteurl='".$surl."',siteshow='".$sshow."' where id='".$id."'";
       
        $db->execute($update_slinfo_sql);
        echo "<script language='javascript'>window.alert('您已经于 ".$datelog." 成功修改【".$sname."】友情链接信息!');location.href='updatelinks.php".$par."';</script>";
       

}
?>
</body>
</html>
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖
台州维博网络(www.tzweb.com)专门运用PHP+MYSQL/ASP.NET+MSSQL技术开发网站门户平台系统等。
2#
 楼主| 发表于 2007-9-30 15:28:20 | 只看该作者
台州网址导航
per_jslib.js代码

/*列表选择*/
function js_set_sel(obj, val)
{        
    for (i=0; i<obj.length; i++)
    {
        if (obj.options.value == val)
        {
            obj.options.selected = true;
            break;
        }
    }
}
台州维博网络(www.tzweb.com)专门运用PHP+MYSQL/ASP.NET+MSSQL技术开发网站门户平台系统等。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

网站推广
关于我们
  • 台州朗动科技(Tzweb.com)拥有多年开发网站平台系统门户手机客户端等业务的成功经验。主要从事:政企网站,系统平台,微信公众号,各类小程序,手机APP客户端,浙里办微应用,浙政钉微应用、主机域名、虚拟空间、后期维护等服务,满足不同企业公司的需求,是台州地区领先的网络技术服务商!

Hi,扫描关注我

Copyright © 2005-2026 站长论坛 All rights reserved

Powered by 站长论坛 with TZWEB Update Techonolgy Support

快速回复 返回顶部 返回列表