Home > Backend Development > PHP Tutorial > PHP链接MYSQL编辑问题

PHP链接MYSQL编辑问题

WBOY
Release: 2016-06-23 14:04:26
Original
801 people have browsed it

xx.php?id=123 

这里打开SQL里相关值,把里面原来的值显示出来 然后可以编辑 再保存到原来的ID下,这样的PHP页面要怎么写呢。想了半天不明白


回复讨论(解决方案)



SQL表

链接SQL文件如下

<?php$conn = @mysql_connect("localhost","用户","密码");if (!$conn){    die("连接数据库失败:" . mysql_error());}mysql_select_db("数据库名称", $conn);mysql_query("set names 'gb2312'");?>
Copy after login

链接SQL的PHP为 inc.php

查询显示和修改需要单独完成
查询

$link=@mysql_connect(LOCALLHOST,USER,PASS) or die('数据库连接失败!');mysql_select_db(DBNAME,$link);mysql_query('set name gb2312');$sql="select * from 表名";$result=mysql_query($sql,$link);echo '<table width="500">';while($row=mysql_fetch_assoc($result)){   echo '<tr>';   echo '<td>'.$row['id'].'</td>';         ......   echo '</tr>';}echo '</table>';mysql_free_result($result);mysql_close($link);
Copy after login

修改
在表单页面中,把想要修改的数据的ID传到编辑页面,在编辑页面点"修改"按钮后传到动做页面(执行上述连接数据库的操作,执行修改)

查询显示和修改需要单独完成
查询


PHP code
?



12345678910111213141516

$link=@mysql_connect(LOCALLHOST,USER,PASS) or die('数据库连接失败!'); mysql_select_db(DBNAME,$link); mysql_query('set name gb2312'); $sql=……
还是不怎么明白,来个类子吧,大神

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template