今天的面试题
<?php $mysql_sname = 'localhost'; //用户名 $mysql_uname = 'root'; //密码 $mysql_upwd = '12345'; //数据库名 $mysql_dbname = 'test'; //链接数据库 $conn = mysql_connect($mysql_sname,$mysql_uname,$mysql_upwd) or die("数据库链接失败!"); //选择数据库 $db_select = mysql_select_db($mysql_dbname, $conn); //查询 $sql_s = "select * from a"; //执行sql $result = mysql_query($sql_s,$conn); //显示查询结果 while($row = mysql_fetch_row($result)){ echo "<br/>"; for($i=0;$i<count($row);$i++){ echo "<td>".$row[$i]."</td>"; } } //删除 $sql_d = "delete from a where id=8"; mysql_query($sql_d,$conn); //增加 $sql_i = " INSERT into a VALUES ( '', 'asd', '666') "; mysql_query($sql_i,$conn); //修改 $sql_u = "update a set name = 'sdfsdfsdf' where id =7 "; mysql_query($sql_u,$conn); mysql_close($conn); ?>