怎样默认选中下拉列表的某一项

输入图片说明输入图片说明输入图片说明截图

想要默认选中下拉列表的某一个分类

<?php 
	include_once("./connect.php");
	$sql="select * from ts_news_cates";//要执行的语句
	$re=mysql_query($sql);//执行命令	
	/*
		定义一个空数组;
		如果执行的语句行数大于0.(说明执行成功,有记录条数)
		输出一个结果(
			要用循环做出来,不知道循环多少次,用while循环。
			把上面执行的sql语句的结$re放在关联数组$info中;
			当这个$info 数组不为假时,把$info的结果放在数组$arr中。
		)
		getCates($arr);是在引用的页面定义的一个函数;
		把getCates函数调用一下,结果放在$infos变量中。
	*/
	$arr=array();
	if(mysql_num_rows($re)>0){
		while(($info=mysql_fetch_assoc($re))!=false){
			$arr[]=$info;
		}
	}
	$infos=getCates($arr);
	$cid=$_GET['cid'];
	echo $cid;
?>
<!DOCTYPE HTML >
<html>

	<head>
		<title> 添加新闻子分类 </title>
		<meta charset="utf-8">
		<meta name="Author" content="">
		<meta name="Keywords" content="">
		<meta name="Description" content="">
		<link rel="stylesheet" type="text/css" href="skin/css/base.css"/>
		<link rel="stylesheet" type="text/css" href="skin/css/main.css"/>
	</head>

	<body leftmargin="8" topmargin='8'>
			<table width="98%" 
			align="center" 
			border="0" 
			cellpadding="3" 
			cellspacing="1" 
			bgcolor="#CBD8AC" 
			style="margin-bottom:8px;margin-top:8px;" 
			>
				<tr>
					<td background="skin/images/frame/wbg.gif" bgcolor="#EEF4EA" class='title' colspan="2">
						<span>
							<img src='skin/images/frame/arr3.gif' style='margin-right:10px;'>添加新闻子分类
						</span>
					</td>
				</tr>
				<tr bgcolor="#FFFFFF">
					<td>
						<form action="./act_add_newscates.php" method="post">
						
						<table style="margin-bottom:8px;margin-top:8px;margin-left:20px;" >
							<tr>
								<td width="100px;">上级分类:</td>
								<td>
									<select name="fid">
										<option value=0>顶级分类</option>
										<!--遍历$infos数组-->
										<?php foreach($infos as $key=>$vo){?>						
										<option value=<?="1"?> selected>
										<?=str_repeat("&nbsp;&nbsp;",$vo['level']-1).$vo['cname']?>
										</option>
										<?php }?>
									</select>
								</td>
							</tr>
							<tr>
								<td>分类名称:</td>
								<td>
									<input type="text" name="cname" value=""/>
								</td>
							</tr>
							<tr>
								<td>首页是否显示</td>
								<td>
									
									<input type="radio" name="show" value="1" checked="true">显示
									<input type="radio" name="show" value="0">不显示
									
								</td>
							</tr>
							<tr>
								<td colspan="2" align="center" height="40px">
									<input type="submit" name="sub" value="添加" class="coolbt2">
								</td>
							</tr>
						</table>
						</form>
					</td>
				</tr>
			</table>		
	</body>
</html>
	
	

转载于:https://my.oschina.net/jackalice/blog/698253

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值