Add interface
<! DOCTYPE html Public "-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >View Code<?PHP$id=$_post["id"];$title=$_post["title"];$author=$_post["Author"];$source=$_post["Source"];$content=$_post["Content"];$time=$_post["Time"];include("dbda.class.php");$db=NewDbda ();$t=Date(' y-m-d h:i:s ');$sql= "INSERT into news values (' {$id}‘,‘{$title}‘,‘{$author}‘,‘{$source}‘,‘{$content}‘,‘{$t}‘)";$r=$db->query ($sql, 0, "Newssystem");if($r){ Header("location:xiti.php"); } Else { Echo"Modify Failed"; }
View CodeQuery interface
<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > Time</td><td>delete</td><td>update</td></tr><?PHPinclude("dbda.class.php");$db=NewDbda ();$sql= "Select Id,title,author,source,time from News";$attr=$db->query ($sql, 1, "Newssystem");foreach($attr as $v){ Echo"<tr> <td>{$v[0]}</td> <td>{$v[1]}</td> <td>{$v[2]}</td> <td>{$v[3]}</td> <td>{$v[4]}</td> <td><a href= ' shanchuchuli.php?id={$v[0]} ' >delete</a></td> <td><a href= ' xiugaichuli.php?id={$v[0]} ' >update</a></td> </tr>"; }? ></table><a href= "xiti.php" > Back </a></body>View CodeDelete Processing
<?PHP$id=$_get["id"];include("dbda.class.php");$db=NewDbda ();$sql= "Delete from news where id= ' {$id}‘";$a=$db->query ($sql, 0, "Newssystem");if($a){ Header("location:biaoge.php"); } Else { Echo"Delete Failed"; }
View CodeModify Interface
<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >PHP$id=$_get["id"];$db=NewMysqli ("localhost", "root", "" "," Newssystem ");$sql= "SELECT * from news where id= ' {$id}‘";$result=$db->query ($sql);$attr=$result-Fetch_row ();><form action= "xiugai.php" method= "POST" ><table width= "100%" border= "0" cellpadding= "2" cellspacing= "2" ><tr><td></td><td><input type= "hidden" name= "id" value= "<?php Echo$attr[0]?> "/></td></tr><tr><td align=" right "> title: </td><td><input type=" Text "name=" title "Value=" <?php Echo$attr[1]?> "/></TD></TR><TR><TD align=" right "></td><td><input type=" text " Name= "Author" value= "<?php Echo$attr[2]?> "/></TD></TR><TR><TD align=" right "> Source: </td><td><input type=" Text "name=" source "value=" <?php Echo$attr[3]?> "/></TD></TR><TD align=" right "> Content: </td><td><textarea cols=" rows= " "5" name= "Content" value= "<?php Echo$attr[4]?> "></textarea></td></tr><tr><td></td><td><input type=" Hidden "name=" Time "value=" <?php Echo$attr[5]?> "/></td></tr></table><div><input type=" Submit "value=" Modify "/></div> </form><div><a href= "biaoge.php" ><input type= "Submit" value= "View"/></a></div> </body>View Code<?PHP$id=$_post["id"];$title=$_post["title"];$author=$_post["Author"];$source=$_post["Source"];$content=$_post["Content"];$time=$_post["Time"];include("dbda.class.php");$db=NewDbda ();$t=Date(' y-m-d h:i:s ');$sql= "Update news set title= ' {$title} ', author= ' {$author} ', source= ' {$source} ', Time= ' {$t} ' where id= ' {$id}‘";$r=$db->query ($sql, 0, "Newssystem");if($r){ Header("location:xiti.php"); } Else { Echo"Add Failed"; }
View CodePHP additions and deletions to check the practice