如何在php中发布查询 [英] how to post query in php

查看:81
本文介绍了如何在php中发布查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问:如何将数据插入数据并从数据库中获取?.

Q.how to insert data into data and get from database?.

推荐答案

如果我正确理解了您的问题,那么您是在询问从数据库中获取数据并进行保存.数据到数据库.

我假设您使用MySQL(如果看不到您的db系统的php文档),则其原理是完全相同的.

对于这两种操作,您都必须连接到数据库.
If I understand your question correctly you are asking about getting data from database and saving data to database.

I assume you use MySQL (if not see php documentation for your db system), nevertheless the principals are quite the same.

For both operations you have to connect to your database.
if (


connection = mysql_connect(''your database server adress'',''your database username'',''your database password'')) { // connection established successfully echo ''Connected to the database''; } else { die(''Error in connecting to the database!''); }
connection = mysql_connect(''your database server adress'',''your database username'',''your database password'')) { // connection established successfully echo ''Connected to the database''; } else { die(''Error in connecting to the database!''); }


您可以从托管服务提供商处获取有关地址,用户名和密码的信息.

获取数据
接下来,您必须编写一个SQL命令字符串.
为了从数据库表中获取所有数据:


You can get the information about the adress, username and password from your hosting provider.

Getting the data
Next you have to write a SQL command string.
For getting all the data from the database table:


sql="SELECT * FROM tablename;";
sql="SELECT * FROM tablename;";


您可以指定要检索的数据(有关更多信息,请阅读SQL文档),例如:


You can specify which data to retrieve (for more information read the SQL documentation) for example:


这篇关于如何在php中发布查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆