<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd "> <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/> <title> Talent List </title> <link href= "style.css tutorial" type= "Text/css" rel= "stylesheet"/> <body> <div id= "Wrap" > <div id= "Main" > <?php if ($action = = ' Add ') { ?> <form action= "? Action=save" method= "Post" Name= "Form1" > <table width= "border=" 0 "cellspacing=" 0 "cellpadding=" 0 "class=" POST "> <tr> <TD colspan= "2" > Add people </td></tr> <TR><TD width= > Login account </td> <TD width= "><input" name= "Login" type= "text" id= "Login"/></td> </tr> <tr> <td> Login Password </td> <td><input name= "PWS" type= "text" id= "PWS"/></td> </tr> <tr> <td> issues </td> <td><input name= "question" type= "text" id= "question"/></td> </tr> <tr> <td> Answers </td> <td><input name= "Answer" type= "text" id= "Answer"/></td> </tr> <tr> <TD colspan= "2" ><input name= "button" type= "Submit" id= "button" value= "Add"/></td> </tr>
</table> </form> <?php } ElseIf ($action = = ' Save ') { $login = isset ($_post[' login ')? $_post[' login ']: '; $PWS = isset ($_post[' PWS '))? $_post[' PWS ']: '; $question = isset ($_post[' question '))? $_post[' question ']: '; $answer = isset ($_post[' answer '))? $_post[' answer ']: '; $sql = "INSERT into person (login,pws,question,answer) VALUES (' $login ', ' $pws ', ' $question ', ' $answer '); $db->query ($sql); Forward (' Publish success ', ' href ', ' personlist.php '); } ElseIf ($action = = ' del ') { $person _id=$_get[' person_id ']; $page =$_get[' page ']; $sql = "Delete from the person where person_id= ' $person _id '"; $db->query ($sql); Forward (' delete success ', ' href ', ' personlist.php?page= '. $page); } ElseIf ($action = = ' Editsave ') { $person _id = isset ($_post[' person_id '))? $_post[' person_id ']: '; $page = isset ($_post[' page ')? $_post[' page ']: '; $login = isset ($_post[' login ')? $_post[' login ']: '; $PWS = isset ($_post[' PWS '))? $_post[' PWS ']: '; $question = isset ($_post[' question '))? $_post[' question ']: '; $answer = isset ($_post[' answer '))? $_post[' answer ']: '; $sql = "Update person set login= ' $login ', pws= ' $PWS ', question= ' $question ', answer= ' $answer ' where person_id= ' $person _ Id ' "; $db->query ($sql); Forward (' Modify success ', ' href ', ' personlist.php?page= '. $page); } ElseIf ($action = = ' edit ') { $person _id=$_get[' person_id ']; $page =$_get[' page ']; $sql = "SELECT * from person where person_id= ' $person _id '"; $query = $db->query ($sql); $row = $db->fetch_array ($query); $login = $row [' Login ']; $PWS = $row [' PWS ']; $question = $row [' Question ']; $answer = $row [' answer ']; ?> <form action= "? Action=editsave" method= "Post" Name= "Form1" > <table width= "border=" 0 "cellspacing=" 0 "cellpadding=" 0 "class=" POST "> <tr> <input name= "page" type= "hidden" value= "<?php echo $page?>"/> <input name= "person_id" type= "hidden" value= "<?php echo $person _id?>"/> <TD colspan= "2" > Modify Personnel </td></tr> <TR><TD width= > Login account </td> <TD width= "><input" name= "Login" type= "text" id= "login" value= "<?php echo $login?>"/></td> </tr> <tr> <td> Login Password </td> <td><input name= "PWS" type= "text" id= "PWS" value= "<?php echo $pws?>"/></td> </tr> <tr> <td> issues </td> <td><input name= "question" type= "text" id= "question" value= "<?php echo $question?>"/></td> </tr> <tr> <td> Answers </td> <td><input name= "Answer" type= "text" id= "answer" value= "<?php echo $answer?>"/></td> </tr> <tr> <TD colspan= "2" ><input name= "button" type= "Submit" id= "button" value= "Modify"/></td> </tr>
</table> </form> <?php } else{ $page = isset ($_get[' page ')? Intval ($_get[' page '): 1; $num = 5; $sql = "SELECT * from person"; $query = $db->query ($sql); $totalnum = $db->num_rows ($query)//Total Records $pagenum = Ceil ($totalnum/$num); Total pages $offset = ($page-1) * $NUM; $sql = $sql. "Limit $offset, $num"; $query = $db->query ($sql)//Get a record ?> <table width= "639" border= "0" cellspacing= "0" cellpadding= "0" class= "POST" > <tr> <TD colspan= "6" > Total records: <?php echo $totalnum;? > ———— <a href= "Personlist.php?action=add" > Add people </a></td></tr> <TR><TD width= "126" > Login account </td> <TD width= > Login Password </td> <TD width= > Problem </td> <TD width= > Answer </td> <TD width= "138" > Add time </td> <TD width= > Operation </td> </tr> <?php while ($row = $db->fetch_array ($query)) { ?> <tr> <td><?php echo $row [' login '];? ></td> <td><?php echo $row [' PWS '];? ></td> <td><?php echo $row [' question '];? ></td> <td><?php echo $row [' answer '];? ></td> <td><?php echo $row [' addtime '];? ></td> <td><a href= "? action=del&person_id=<?php echo $row [' person_id ']? >&page=<?php echo $page? > "> Delete </a>/ <a href= "? action=edit&person_id=<?php echo $row [' person_id ']? >&page=<?php echo $page?>" > Modify </a></td> </tr> <?php } ?> </table> </div> <div id= "Pages_btns" > <div class= "pages" ><?php showpage ($page, $num, $pagenum, $totalnum)?></div> </div> <?php } ?> </div> </body> |