1个回答
展开全部
//连接数据库
$link = mysql_connect($db_host, $db_username, $db_password);
//查询。tablename为表名
$sql = "SELECT * FROM tablename";
$res = mysql_query($sql,$link);
while($a = mysql_fetch_array($res))
{
echo 'Name:'.$a['name'].',Grade:'.$a['grade'].'<br>';
}
//添加
$sql = "INSERT INTO tablename (name,grade) VALUES ('李四','88')";
mysql_query($sql,$link);
//删除
$sql = "DELETE FROM tablename WHERE name='张三'";
mysql_query($sql,$link);
//修改
$sql = "UPDATE tablename SET grade=90 WHERE name='张三'";
mysql_query($sql,$link);
$link = mysql_connect($db_host, $db_username, $db_password);
//查询。tablename为表名
$sql = "SELECT * FROM tablename";
$res = mysql_query($sql,$link);
while($a = mysql_fetch_array($res))
{
echo 'Name:'.$a['name'].',Grade:'.$a['grade'].'<br>';
}
//添加
$sql = "INSERT INTO tablename (name,grade) VALUES ('李四','88')";
mysql_query($sql,$link);
//删除
$sql = "DELETE FROM tablename WHERE name='张三'";
mysql_query($sql,$link);
//修改
$sql = "UPDATE tablename SET grade=90 WHERE name='张三'";
mysql_query($sql,$link);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询