版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、本文實(shí)例為大家分享了php學(xué)生管理系統(tǒng)源碼,供大家參考,具體內(nèi)容如下功能:&n bsp;1添加/刪除/修改2數(shù)據(jù)存儲界面分布:index.php ->主界面add.php ->stu 添加頁面跳action -> sql 中 add/del/update (處理 html 表單->mysql 的數(shù)據(jù)存儲 & 轉(zhuǎn))edit.php ->stu 修改menu.php ->首頁1. in dex.php& lt;!DOCTYPE html >& lt;html la ng=e n>& t;head >&n bsp; & lt;meta chars
2、et=UTF-8> &t;title>學(xué)生信息管理 </title>&n bsp; & t;script>&n bsp; &n bsp; fun cti on doDel(id) if(confirm( 確認(rèn)刪除?)&n bsp; &n bsp; &n bsp; &n bsp; win dow .lo cati on=act ion. php?act ion=del& amp;id=+id;&n bsp; &n bsp; &n bsp; &n bsp; &n bsp; &n bsp; & t;/script &
3、gt;</head >& t;body >& lt;ce nter>&n bsp; & t;?php&n bsp; in clude (me nu .php);&n bsp; ?> &It;h3>瀏覽學(xué)生信息 &It;/h3>&n bsp; & lt;table width=500 border=1>&n bsp; &n bsp; & lt;tr>&n bsp; &n bsp; &n bsp; <th >ID & lt;/th>姓名& lt;/th > 性別& lt;/th > 年齡& lt;/th
4、 > 班級& t;/th > 操作& lt;/th >&n bsp; &n bsp; &n bsp; & lt;th > &n bsp; &n bsp; &n bsp; & lt;th > &n bsp; &n bsp; &n bsp; & lt;th > &n bsp; &n bsp; &n bsp; & lt;th > &n bsp; &n bsp; &n bsp; & lt;th > &n bsp; &n bsp; & t;/tr>&n bsp; &n bsp; & t;?php/ &n bsp; &n bsp;1.鏈接數(shù)據(jù)庫&n b
5、sp; &n bsp; try&n bsp; &n bsp; &n bsp; $pdo = new PDO(uri:mysqlPdo.i ni,root,1);&n bsp; &n bsp; catch (PDOException $e) &n bsp; &n bsp; &n bsp; die(c onnection failed.$e->getMessage();&n bsp; &n bsp; 2.執(zhí)行 sql&n bsp; &n bsp; $sql_select = select * from stu; 3.data 解析&n b
6、sp; &n bsp; foreach ( $pdo->query($sql_select) as $row) &n bsp; &n bsp; &n bsp; echo <tr>&n bsp; &n bsp; &n bsp; echo <th >$rowid </th >&n bsp; &n bsp; &n bsp; echo <th >$row name</th >&n bsp; &n bsp; &n bsp; echo <th >$rowsex </th>&n bsp; &n bsp; &n bsp;
7、 echo <th >$rowage </th>&n bsp; &n bsp; &n bsp; echo <th >$rowclassid</th >&n bsp; &n bsp; &n bsp; echo <td > &t;a href=edit.php?id=$rowid>修改</a>&n bsp; &n bsp; &n bsp; &n bsp;&n bsp;<a href=javascript:void(0);on click=doDel
8、($rowid) >刪除 </a>&n bsp; &n bsp; &n bsp; &n bsp; & lt;/td >&n bsp; &n bsp; &n bsp; echo </tr>&n bsp; &n bsp; &n bsp; &n bsp; ?>&n bsp; & t;/table >& lt;/ce nter>& t;/body >& lt;/html>2. add.php&n bsp;& lt;!DOCTYPE html >& lt;html la ng=e n>& lt;head >&n bsp;
9、 & lt;meta charset=UTF-8> &t;title>學(xué)生管理系統(tǒng) </title></head >& lt;body >& lt;ce nter>&n bsp; <?php in clude (me nu .php); ?& gt; &It;h3>增加學(xué)生信息 &It;/h3>&n bsp; <form action=acti on .php?act ion=add method=post>&n bsp; &n bsp; & lt;table>&n bsp; &n bs
10、p; &n bsp; & lt;tr>&n bsp; &n bsp; &n bsp; &n bsp; & lt;td >姓名& lt;/td >&n bsp;&n bsp;&n bsp;&n bsp;& lt;td >< in puttype=text name= name> </td >&n bsp; &n bsp; &n bsp; & t;/tr>&n bsp; &n bsp; &n bsp; & lt;tr>&n bsp; &n bsp; &n bsp; &n bsp; & lt;td > 年齡& lt;/td >&
11、n bsp; &n bsp; &n bsp; &n bsp; & lt;td >< in put type=text name=age > ;</td >&n bsp; &n bsp; &n bsp; & t;/tr>&n bsp; &n bsp; &n bsp; & lt;tr>&n bsp; &n bsp; &n bsp; &n bsp; & lt;td >性別& lt;/td > <td><inputtype=radioname=sex value=男>男&t;/td
12、> <td><inputtype=radioname=sex value=女>女&t;/td>&n bsp; &n bsp; &n bsp; & t;/tr>&n bsp; &n bsp; &n bsp; & lt;tr>&n bsp; &n bsp; &n bsp; &n bsp; & lt;td >班級& lt;/td >&n bsp;&n bsp;&n bsp; &n bsp;& lt;td >< in puttype=textname=classid></t
13、d >&n bsp; &n bsp; &n bsp; & t;/tr>&n bsp; &n bsp; &n bsp; & lt;tr>& t;!- &n bsp; &n bsp; &n bsp; &n bsp ;& lt;td > & lt;/td >-> <td><a href=index.php>返回 </td> <td><inputtype=submit value=添加></td &
14、gt; <td><inputtype=reset value=重置></td >&n bsp; &n bsp; &n bsp; & t;/tr>&n bsp; &n bsp; & t;/table > ;&n bsp;&n bsp; </form >& lt;/ce nter>& t;/body >& lt;/html>3. action, php&n bsp;& t;?php/*&n bsp;* Created by PhpStorm.&n bsp;* User: hy
15、h&n bsp;* Date: 16-7-7 * Time:下午 9:37&n bsp;*/1.鏈接數(shù)據(jù)庫try&n bsp; $pdo = new PDO(uri:mysqlPdo.i ni,root,1);catch (PDOException $e) / &n bsp; &n bsp; &n bsp;echo Connection failed: . $e->getMessage();&n bsp; die(c onnection failed.$e->getMessage();2.action的值做對操作switch ($_GETactio n)&n bsp; c
16、ase add:/add&n bsp;&n bsp; &n bsp; $n ame = $_POST name;&n bsp; &n bsp; $sex = $_POSTsex;&n bsp; &n bsp; $age = $_POSTage;&n bsp; &n bsp; $classid = $_POSTclassid;&n bsp; &n bsp; &n bsp;&n bsp; $sql = insert into stu (name, sex, age, classid) values ($name.$sex,$age,$classid);&n bsp; &n
17、 bsp; $rw = $pdo->exec($sql);&n bsp;&n bsp; &n bsp; if ($rw & gt; 0) echo <script>alter(添加成功);</script>&n bsp; &n bsp; else echo <script>alter(添加失敗);</script>&n bsp; &n bsp; &n bsp; &n bsp; header(Locati on: in dex.php);&n bsp; &n bs
18、p; break ;&n bsp;&n bsp; case del:/get&n bsp; &n bsp; $id = $_GETid;&n bsp; &n bsp; $sql = delete from stu where id=$id;&n bsp; &n bsp; $rw = $pdo->exec($sql);&n bsp; &n bsp; if ($rw > 0) echo <script>alter(刪除成功);</script>&n bsp; &n bsp; else
19、 echo <script>alter(刪除失敗);</script>&n bsp; &n bsp; &n bsp; &n bsp; header(Locati on: in dex.php);&n bsp; &n bsp; break;&n bsp; case edit:/post&n bsp; &n bsp; $id = $_POSTid;&n bsp; &n bsp; $n ame = $_POST name;&n bsp;&n bsp; &n bsp; $age = $_POSTage;&n bsp; &n bsp; $classid = $_POSTclass
20、id;&n bsp; &n bsp; $sex = $_POSTsex;&n bsp; &n bsp; &n bsp;&n bsp;/ &n bsp; &n bsp;echo $id, $age, $age, $n ame;&n bsp;&n bsp; $sql = update stu setn ame=$ name,age=$age,sex=$sex,classid=$classid where id=$id;/ $sql = update myapp.stu set name=jike,sex= 女,age=24,classid=44 where id=17;&
21、n bsp; &n bsp; print $sql;&n bsp; &n bsp; $rw = $pdo->exec($sql);&n bsp; &n bsp; if ($rw > 0) echo <script>alter(更新成功);</script>&n bsp; &n bsp; else echo <script>alter(更新失敗);</script>&n bsp; &n bsp; &n bsp; &n bsp; header(Locati o
22、n: in dex.php);&n bsp; &n bsp; break ;&n bsp;&n bsp; default:&n bsp; &n bsp; header(Locati on: in dex.php);&n bsp; &n bsp; break;4. edit.php& lt;!DOCTYPE html >& lt;html la ng=e n>& lt;head >&n bsp; & lt;meta charset=UTF-8> &t;title>學(xué)生管理系統(tǒng) </title></head >& lt;body &
23、gt;& lt;ce nter>&n bsp; <?php in clude (me nu .php); /1.鏈接數(shù)據(jù)庫&n bsp; try&n bsp; &n bsp; $pdo = new PDO(uri:mysqlPdo.i ni,root,1);&n bsp; catch (PDOException $e) &n bsp; &n bsp; die(c onnection failed.$e->getMessage();&n bsp; /2.執(zhí)行 sql&n bsp; $sql_select = select * from stu wher
24、e id=$_GETid;&n bsp; $stmt = $pdo->query($sql_select);&n bsp; if ($stmt->rowCou nt() >0) &n bsp; &n bsp; $stu = $stmt->fetch(PDO:FETCH_ASSOC); /解析數(shù)據(jù)&n bsp; else&n bsp; &n bsp; die( no have this id:$_GETid);&n bsp; &n bsp; ?> &It;h3>修改學(xué)生信息 &It;/h3>&n bsp; <form action=ac
25、ti on .php?act ion=edit method=post >echo&n bsp;&n bsp;<i nput type=hidde nn ame=idvalue=<?php$stuid;?>>&n bsp; &n bsp; & lt;table>&n bsp; &n bsp; &n bsp; & lt;tr>&n bsp; &n bsp; &n bsp; &n bsp; & lt;td >姓名& lt;/td >&n bsp;&n bsp;&n bsp;&n bsp;<td > ;& lt;i nputtype=t
26、extn ame=n amevalue=<?php echo $stu name;? >></td >&n bsp; &n bsp; &n bsp; & t;/tr>&n bsp; &n bsp; &n bsp; & lt;tr>&n bsp; &n bsp; &n bsp; &n bsp; & lt;td >年齡& lt;/td >&n bsp; &n bsp;&n bsp;&n bsp;<td > ;<i nputtype=text n ame=agevalue=<?php echo $stuage;? >&
27、gt;</td >&n bsp; &n bsp; &n bsp; & t;/tr>&n bsp; &n bsp; &n bsp; & lt;tr>&n bsp; &n bsp; &n bsp; &n bsp; & lt;td >性別& lt;/td >&n bsp; &n bsp; &n bsp; &n bsp; & lt;td > <input type=radio name=sex value=男 <?php echo ($stusex=男)? checked:;?&g
28、t; >男&n bsp; &n bsp; &n bsp; &n bsp; </td >&n bsp; &n bsp; &n bsp; &n bsp; & lt;td > <input type=radio name=sex value=女 <?php echo ($stusex=女)? checked:;?> >女&n bsp; &n bsp; &n bsp; &n bsp; </td >&n bsp; &n bsp; &n bsp; & t;/tr>&n bsp; &
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 《電機(jī)拖動學(xué)》課件
- 2024年浙教新版四年級數(shù)學(xué)上冊階段測試試卷
- 臨時工工作守則
- 公園建設(shè)機(jī)械費(fèi)施工合同
- 購物中心美食城租賃合同
- 體育賽事項(xiàng)目招標(biāo)承諾
- 銷售技能提升手冊
- 臨時醫(yī)療電腦租賃合同樣本
- 2024年人教版PEP高一數(shù)學(xué)下冊階段測試試卷
- 通信設(shè)備采購?fù)稑?biāo)報(bào)價(jià)表
- 工業(yè)項(xiàng)目投資估算及財(cái)務(wù)評價(jià)附表(有計(jì)算公式)
- 2024-2030年中國Micro LED行業(yè)發(fā)展現(xiàn)狀調(diào)研及市場前景趨勢報(bào)告
- 醫(yī)療機(jī)構(gòu)病歷管理規(guī)定(2024 年版)
- 高中英語外研版 單詞表 必修2
- 2024-2030年中國蓖麻行業(yè)市場發(fā)展趨勢與前景展望戰(zhàn)略分析報(bào)告
- 2025國家開放大學(xué)電大??啤痘A(chǔ)寫作》期末試題及答案(試卷號2412)
- 用所給詞的適當(dāng)形式填空(專項(xiàng)訓(xùn)練)人教PEP版英語六年級上冊
- 2024年全國職業(yè)院校技能大賽“新型電力系統(tǒng)與維護(hù)”賽項(xiàng)考試題庫-中(多選題)
- DL∕T 677-2018 發(fā)電廠在線化學(xué)儀表檢驗(yàn)規(guī)程
- 馬克思主義與社會科學(xué)方法論課后思考題答案全
- 七年級歷史下冊教學(xué)工作計(jì)劃
評論
0/150
提交評論