首页 > 代码库 > 数据库查询表单值
数据库查询表单值
1.链接数据库通用方法:conn.php <?php //第一步:链接数据库 $conn=@mysql_connect("localhost:3306","root","root")or die ("mysql链接失败"); //第二步: 选择指定的数据库,设置字符集 @mysql_select_db("php_blog",$conn) or die ("db链接失败".mysql_error()); mysql_query(‘SET NAMES UTF8‘)or die ("字符集设置错误"); ?> 2.查询判断 select.php <?php include("conn.php");//引入链接数据库<pre name="code" class="html"><?php include("conn.php");//引入链接数据库 if(!empty ($_GET[‘id‘])){ $sql="select * from news where id=‘".$_GET[‘id‘]."‘"; $query=mysql_query($sql); $rs=mysql_fetch_array($query); //判断$rs有值说明数据库存在,否则数据库不存在; } ?> <form action="add.php" method="post"> 标题: <input type="text" name="title"><br> 内容: <textarea rows="5" cols="50" name="con"></textarea><br> <input type="submit" name="sub" value="发表"> </form>
数据库查询表单值
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。