本文章介绍了一个简单的删除数据库的记录时再刷新当前页面,这个不是用ajax实现的而是用了get方式来刷新当前页面,这个方法在实际应用中用户体验并不好,主要学下方法吧。
功能:
1、在某个页面上显示查询数据,并在每条数据后增加删除功能,点击“删除”,删除掉数据,同时刷新页面
2、用GET方式获得删除条件
数据库连接变量connectvars.php,代码如下:
- <?php
- //服务器
- define('DB_HOST', 'localhost');
- //用户名
- define('DB_USER', 'root');
- //密码
- define('DB_PASSWORD', 'root');
- //数据库
- define('DB_NAME','test') ;
- ?>
记录展示页面display.php,每条记录后有“删除”功能,点击“删除”,可删除该条记录,同时刷新页面,代码如下:
- <?php
- require_once 'connectvars.php';
- $dbc = mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
- //如果调用此页面时,页面链接中有‘DelID’变量,则获得要删除记录的‘ID’号,进行删除
- if(isset($_GET['DelID'])){
- $query = "DELETE FROM toyota WHERE ID = ".$_GET['DelID']." LIMIT 1";
- mysqli_query($dbc,$query);
- }
- //查出所有记录,并在接下来的表格中进行显示(如果上面的删除代码被执行,此处相当于刷新页面)
- $query = "SELECT * FROM toyota ORDER BY ID DESC";
- $data = mysqli_query($dbc,$query);
- //统计所查询出的记录条数
- $count = mysqli_num_rows($data);
- ?>
- <html>
- <head>
- <title>丰田汽车数据查看</title>
- </head>
- <body>
- <table>
- <!– 表格列名 –>
- <tr>
- <th>标题</th>
- <th>来源</th>
- <th>车型</th>
- <th>主要部件</th>
- <th>操作</th>
- </tr>
- <?php
- //循环输出列表元素:title、source、carType、majorPart,后加一个"删除"链接
- while($row = mysqli_fetch_array($data)){
- echo '<tr>';
- echo '<td><a href = '.$row['url'].'>'.$row['title'].'</td>';
- echo '<td>'.$row['source'].'</td>';
- echo '<td>'.$row['carType'].'</td>';
- echo '<td>'.$row['majorPart'].'</td>';
- //点击"删除"链接,调用自身页面,同时在页面链接上增加‘DelID’变量,赋值为该记录在数据库中的‘ID’号,用于GET方式获得
- echo '<td><a href = "'.$_SERVER['PHP_SELF'].'?DelID='.$row['ID'].'">删除</a></td>';
- echo '</tr>';
- }
- ?>
- </table>
- </body>
- </html>
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
波比源码 » php中删除页面记录,同时刷新页面实现方法
波比源码 » php中删除页面记录,同时刷新页面实现方法
levaquin 250mg us levaquin 500mg sale
order avodart sale ondansetron 8mg cheap zofran 4mg pills
order spironolactone 25mg generic diflucan 200mg usa diflucan tablet
buy sildenafil 100mg for sale buy nolvadex 10mg generic robaxin 500mg over the counter
lamictal without prescription lamictal 50mg tablet order tretinoin without prescription
indomethacin 75mg cheap order indocin 50mg pill amoxicillin online buy
anastrozole 1mg generic Generic viagra usa sildenafil 100mg usa
acheter 40mg tadalafil en ligne pharmacie en ligne tadalafil 40mg viagra 200mg pour homme
cheap isotretinoin azithromycin online buy ivermectin 6 mg tablets
buy provigil pills buy modafinil 200mg sale buy acetazolamide
altace 10mg canada altace 5mg usa astelin 10 ml generic
order fosamax 35mg online cheap oral ibuprofen purchase famotidine for sale
isosorbide price digoxin price purchase telmisartan
buy zyban 150mg online cheap quetiapine pill buy seroquel 100mg generic
dapsone pill order dapsone 100mg online cheap aceon online buy
order isotretinoin 10mg online cheap generic accutane 20mg prednisone for sale online
order piracetam 800 mg generic sildenafil 150mg price buy sildenafil pill
cialis tadalafil viagra 50mg cheap purchase viagra without prescription
purchase cialis sale cialis 40mg over the counter buy anafranil 25mg for sale
buy chloroquine online order olumiant 4mg generic buy baricitinib 2mg generic
itraconazole generic buy tinidazole 300mg for sale tindamax 500mg us
buy generic norvasc buy tadalafil 5mg buy cialis 5mg online cheap
metoprolol 50mg usa metoprolol 100mg over the counter generic vardenafil 20mg
affordable term papers online roulette for real money gambling addiction
triamcinolone 4mg pills purchase triamcinolone generic order desloratadine 5mg
priligy 90mg brand buy priligy pills buy levothyroxine
order zyloprim 300mg pill crestor 20mg cheap order zetia 10mg generic
buy baclofen 10mg online buy toradol 10mg pills order toradol 10mg without prescription
order zantac generic meloxicam 15mg for sale order celecoxib for sale
order tamsulosin generic buy spironolactone 100mg pills spironolactone 100mg tablet
zocor cheap proscar 5mg price order generic proscar
buy metronidazole 400mg purchase bactrim pills buy trimethoprim online
oral keflex 500mg order keflex 125mg online cheap erythromycin 500mg usa
poker sites over the counter cialis tadalafil tablet
order generic desyrel 100mg order trazodone 100mg generic sildenafil 100mg oral
buy sildalis online lamictal for sale buy lamotrigine 50mg for sale
buy viagra 100mg online cheap order sildenafil 100mg online cheap cialis mail order
zithromax 500mg usa buy azithromycin 250mg pills order neurontin 100mg pill
furosemide 40mg pills hydroxychloroquine for sale online hydroxychloroquine drug
buy sildenafil 100mg online cheap order tamoxifen 10mg generic rhinocort pills
order generic deltasone 5mg mebendazole 100mg tablet vermox pills