关于PHP更新数据库
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /> <html xmlns="http://www.w3.org/1999/xhtml"><br /> <head><br /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br /> <title>无标题文档</title><br /> </head><br /> <body><br /> <form action="insert.php" method="post" target="win"><br /> 请输入新闻的title:<input type="text" name="title" /><br /> 请选择新闻类型:<select name="c_id"><option value="1">体育</option><option value="2">娱乐</option></select><br /> <br /><br /> 请输入新闻的content:<br /><br /> <textarea cols="60" rows="15" name="content"></textarea><br /> <input type="submit" value="提交" /><br /> </form><br /> </body><br /> </html>
<?php<br /> include("connect_mysql.php");<br /> $q = "insert into new(title,content,time,news_cate_id) values('".$_POST["title"]."','".$_POST["content"]."',now(),".$_POST["c_id"].")";<br /> mysql_query($q);<br /> if(mysql_affected_rows()>0) echo "xinwentianjiachenggong!";<br /> ?><br /> <hr /><br /> <a href="add_news.php" target="win">fanhuijixutianjiaxinwen</a>
<?php<br /> function mysql_open()<br /> {<br /> $mysql_servername="localhost"; //<br /> $mysql_username="root";<br /> $mysql_password="11111";<br /> $mysql_dbname="new";<br /> <br /> $conn=mysql_connect($mysql_servername ,$mysql_username ,$mysql_password);<br /> mysql_query("set names UTF8"); //UTF8<br /> mysql_select_db($mysql_dbname , $conn);<br /> return $conn;<br /> }<br /> ?>