将Linux的数据库更新到网页,linux 下将mysql数据库中的表内容显示到网页上

在虚拟机里面做了一遍,实验成功后复制的命令:

yum -y install httpd

/etc/init.d/httpd restart

cd /var/www/html/

echo benwen > index.html

elinks http://192.168.18.2 --dump

benwen

yum -y install mysql mysql-server

use test;

create table gya (name char(20), tel int, addr char(50));

mysql> desc gya;

+-------+----------+------+-----+---------+-------+

| Field | Type     | Null | Key | Default | Extra |

+-------+----------+------+-----+---------+-------+

| name  | char(10) | YES  |     | NULL    |       |

| tel   | int(11)  | YES  |     | NULL    |       |

| addr  | char(50) | YES  |     | NULL    |       |

+-------+----------+------+-----+---------+-------+

3 rows in set (0.00 sec)

yum -y install php

cd /etc/httpd/conf.d

cd /etc/httpd/conf.d/

/etc/init.d/httpd  restart

cd /var/www/html/

vim  mysql.php

$con = mysql_connect("localhost","root","");

if (!$con)

{

die('Could not connect:' . mysql_error());

}

mysql_select_db("test", $con);

$result = mysql_query("SELECT * FROM gya");

while($row = mysql_fetch_array($result))

{

echo $row['name'] . " " . $row['tel'];

echo "
";

}

mysql_close($con);

?>

yum -y php-mysql

81  yum -y install php-mysql

82  /etc/init.d/httpd restart

83  elinks http://192.168.18.2/mysql.php --dump

84  history

85  elinks http://192.168.18.2 --dump

benwen

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值