php与Mysql编程

php与Mysql编程,第1张

<?php

$dbname="dorm"

mysql_connect('localhost','root','root')

$sql = 'SELECT No,Name FROM `member` '

mysql_query("SET NAMES GBK")

$result=mysql_db_query($dbname,$sql)

while($row=mysql_fetch_array($result))

{

echo "<a href=\"MemberDetail.php?id=" . $row["No"] . "\">" . $row["Name"] . "</a>"

}

mysql_free_result($result)

mysql_close()

?>

MemberDetail.php

<?php

$no = $_GET['id']

$dbname="dorm"

mysql_connect('localhost','root','root')

$sql = "SELECT Detail FROM `member` WHERE No = '$no'"

mysql_query("SET NAMES GBK")

$result=mysql_db_query($dbname,$sql)

while($row=mysql_fetch_array($result))

{

echo "$row['Detail']"

}

mysql_free_result($result)

mysql_close()

?>

大致上就是这样子了。

1、SELECT s.name,c.cname FROM student AS s,course AS c,student_course AS r WHERE s.sno = r.sno AND c.cno = r.cno

写入JSON用json_encode()

2、SELECT s.name,c.cname FROM student AS s,course AS c,student_course AS r WHERE s.sno = r.sno AND c.cno = r.cno AND s.sid = 's002'

DELETE FROM student_course WHERE sno = 's002' LIMIT 1

3、INSERT INTO student_course(sno,cno) VALUES('s001','c002'),('s001','c003')


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/6101979.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-14
下一篇 2023-03-14

发表评论

登录后才能评论

评论列表(0条)

保存