$link = mysql_connect("localhost","mysql_user","mysql_password")
$db_selected = mysql_select_db("my_db",$link)
$value = $_POST['typeid']
$text = $_POST['keyword']
switch($value){
case "":
$sql = "SELECT * FROM table WHERE 'bianhao' LIKE '%" . $text . "%'"
break
case 1:
$sql = "SELECT * FROM table WHERE 'name' LIKE '%" . $text . "%'"
break
case 2:
$sql = "SELECT * FROM table WHERE 'dizhi' LIKE '%" . $text . "%'"
break
case 3:
$sql = "SELECT * FROM table WHERE 'riqi' LIKE '%" . $text . "%'"
break
default:
break
}
$res = mysql_query($sql,$link)
print_r(mysql_fetch_array($res))
mysql_close($link)
?>
日期如果是记录时间戳的形式就得另写,可以在前端写一个日期选择器。
<select name="xingming"><option value="<?php echo $row['name']?>" ><?php echo $row['name']?></option>
</select >
应该这么写才能$_POST['xingming']到值
这是我自己用的一段代码,你自己改一下,点一下一级文本框,它所属的文本框会收起或伸展。<SCRIPT language=javascript>
<!--
function menu_tree(meval)
{
var left_n=eval(meval)
if (left_n.style.display=="none")
{ eval(meval+".style.display=''")}
else
{ eval(meval+".style.display='none'")}
}
-->
</SCRIPT>
<TABLE class=navi cellSpacing=1 align=center border=0>
<TBODY>
<TR>
<TH>后台 >>新闻分类</TH></TR></TBODY></TABLE><BR>
<table border=0 cellspacing=1 align=center class=form>
<tr>
<th colspan="2">添加分类</th>
</tr>
<form action="" method="post">
<tr>
<td colspan="2" align="center" height='30'>
<select name="fid">
<option value="0">添加大类</option>
<?php
$query=$db->findall("shipin where fid=0")
while ($row=$db->fetch_array($query)){
$new_class_arr[$row[id]]=$row[name]
echo "<option value=\"$row[id]\">$row[name]</option>"
}
?>
</select>
<input type="text" name="name" value="">
<input type="submit" name="into_class" value="添加分类"/>
</td>
</form>
</tr>
</table>
<br>
<table border=0 cellspacing=1 align=center class=form>
<tr>
<th colspan="2">系统分类</th>
</tr>
<?php
foreach ($new_class_arr as $id=>$val){
?>
<tr>
<td onClick ="javascript:menu_tree('left<?=$id ?>')" >
<form action="" method="post">
<IMG src="images/menu.gif" align=absMiddle border=0>
<input type="hidden" name="id" value="<?php echo $id?>">
<input type="text" name="name" value="<?php echo $val?>">
<input type="submit" name="update_class" value="更新"/>
<input type="button" value="删除" onclick="location.href='?del=<?php echo $id?>'"/>
</form>
</td>
</tr>
<tr id=left<?=$id ?>>
<td>
<table >
<tbody>
<?php
$query_fid=$db->findall("shipin where fid=$id")
while ($row_fid=$db->fetch_array($query_fid)){
?>
<tr>
<td>
<form action="" method="post">
<IMG src="images/menu.gif" align=absMiddle border=0>
<input type="hidden" name="id" value="<?php echo $row_fid[id]?>">
<input type="text" name="name" value="<?php echo $row_fid[name]?>">
<input type="submit" name="update_class" value="更新"/>
<input type="button" value="删除" onclick="location.href='?del=<?php echo $row_fid[id]?>'"/>
</form>
</td></tr>
<?php }?>
</tbody>
</table>
</td>
</tr>
<?php
}
?>
</table>
</BODY></HTML>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)