PHP? ??? ?? ?? ???? ?? ?? ??(1?)
?? ???? ??????? ??? ?????? ??????. ? ?? ??? ???? ??? ? id
<a href="modifynew.php?id? ???? ???? ????? ??? ?? ????? =<? php echo $row['id'];?>">??</a>
<a href="delnew.php?id=<?php echo $row['id' ];?>">??</a>
??, ID? ???? ID? ???? ????? ??? ?? ID? ?? ?? ??? ???? ???. ?? ??? ??? ???????. flow Chart
????? id? ??new.php ??? ?????.
? ???? ??? ??????.
? ????? ??? ?????. ?? ??? ID? ???? ?????. ??????? ??? ?? ?? ??? ?????
?? ??????? ?????:
header("Content-type: text/html; charset=utf-8");// ??? ??
$con =@mysql_connect("localhost ","root","root") ?? die("?????? ?? ??");
mysql_select_db('news') ?? die("??? ??????? ? ? ????." );
mysql_query("set names utf8");/ /??????? ?? ??? ??
? ?? ID? ????
??? ID ??? get ???? ????
$id=$_GET? ????. ['id'];
ID? ???? ??????? ?????
$sql ="select * from new where id=$id";
$res = mysql_query($sql);
$row = mysql_fetch_array($ res);
??? ??? ? ???? ??? ???? ???
html ???? ??? ??? ????.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style type="text/css"> *{margin:0px;padding:0px;} body{background:#ccc;} .add{width:450px;height:280px;background:#eee;float:left;} .cont{width:500px;height:350px;margin-top:5px;margin-left:5px;} form{margin-left:10px;padding-top:30px;} .sub{width:100px;height:40px;border:1px solid #ccc;} .sub:hover{background:#f90} </style> </head> <body> <div class="add"> <div class="cont"> <form method="post" action="modify.php?id=<?php echo $id;?>"> 標題:<input type="text" name="title" value="<?php echo $row['title']?>"></br></br> 內容:<textarea cols="50" rows="5" name="content"><?php echo $row['content']?></textarea></br></br> <input type="submit" value="修改" class="sub"> </form> </div> </div> </body> </html>
??? ?? ???????? ??? ??? ?????
?? ?? ??? ??? ????:
<?php header("Content-type: text/html; charset=utf-8");//設置編碼 $con =@mysql_connect("localhost","root","root") or die("數據庫連接失敗"); mysql_select_db('news') or die("指定的數據庫不能打開"); mysql_query("set names utf8");//設置數據庫的字符集 $id=$_GET['id']; $sql="select * from new where id=$id"; $res = mysql_query($sql); $row = mysql_fetch_array($res); ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style type="text/css"> *{margin:0px;padding:0px;} body{background:#ccc;} .add{width:450px;height:280px;background:#eee;float:left;} .cont{width:500px;height:350px;margin-top:5px;margin-left:5px;} form{margin-left:10px;padding-top:30px;} .sub{width:100px;height:40px;border:1px solid #ccc;} .sub:hover{background:#f90} </style> </head> <body> <div class="add"> <div class="cont"> <form method="post" action="modify.php?id=<?php echo $id;?>"> 標題:<input type="text" name="title" value="<?php echo $row['title']?>"></br></br> 內容:<textarea cols="50" rows="5" name="content"><?php echo $row['content']?></textarea></br></br> <input type="submit" value="修改" class="sub"> </form> </div> </div> </body> </html>