Question:
Could someone please explain just how PHP and SQL and MySQL work together?
Foo Fighter
2016-06-16 07:53:02 UTC
Am quite confused about how these languages work. Still figuring out exactly what a web server, database and data actually are conceptually.

What do you use PHP for?
What do you use MySQL for?
What do you use SQL for?

How do these three things work together?

Am use to working with Java in eclipse and making different classes and making a program work that way. But this whole PHP/SQL thing is different from all that. Is there something I need to download in order to start writing SQL and PHP? I just don't know where to start with the whole SQL and PHP thing. Feeling lost. Don't know when/why to use them but I know they are important to be a well-rounded programer. Is there a similar environment to the Java eclipse thing?

Please help I truly need help!
Thank you
Ten answers:
?
2016-06-20 23:23:09 UTC
simply we can say : php uses MYSQL data to show us something meaningful
Lizard
2016-06-18 22:45:41 UTC
PHP is a programming language. You can write raw PHP code to develop the backend of a website without using any framework, but you need to have a server installed on your machine that will execute the PHP code.

SQL is a language that works with databases, mostly used with the database MySQL.

PHP has an API that integrates SQL queries to work with the MySQL database so you can store the content of your website into a database and then retrieve it.



An example using all this stack is like this:

- Install the server and the database on your machine (XAMPP comes with everything included)

- Run the web server and the database server

- Using the PHP code connect with the database

- Interact with the database to add or retrieve data from the database (You can add that from the PHPMyAdmin that comes with XAMPP and then query the database using PHP)
2016-06-18 02:49:27 UTC
PHP is a programming language like Java and Net. SQL and Mysql is used for database and they work together.
2016-06-17 13:28:56 UTC
php is a .php file containing php code, running in apache webserver which can :

- display html website

- send sql statement to a mysql database server to retrieve data or update data or add new data

java has jsp for php. apache tomcat, jetty, resin for apache webserver.
vedanta
2016-06-17 08:02:45 UTC
php and sql is deadly combination. they. wrok togather
JA12
2016-06-17 07:58:37 UTC
PHP and SQL are Languages. MySQL is a Database and interface.



Definition: PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language.



PHP is a Scripting language that processes data passed from a webpage and may build the HTML that is ultimately displayed on a web page. It is sometimes used to just validate the data entered on a webpage, sometimes storing that data on a database, sometimes retrieving data from a database and generating dynamic HTML to display the results as a webpage.



PHP can be embedded in client side code in the HTML, or be 100% Server-Side scripting triggered by a GET/POST instruction from within the HTML.



Definition: Structured Query Language) is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS), or for stream processing in a relational data stream management system (RDSMS).



SQL is the language used to send and process instructions to and from a Relational Database. Databases all use the same basic set of SQL instructions, but most have unique FUNCTIONS within their own flavour of SQL. Here are some of them:



PL/SQL (Oracle)

T-SQL (SQL Server)

SQL/PSM (PostgreSQL)

Watcom-SQL (Sybase)

SPL (Teradata)



A simple SQL instruction is in the form of:

SELECT * FROM [table] WHERE [column]='something';



Definition: MySQL is an open-source relational database management system (RDBMS)



MySQL, currently owned by Oracle, comes with its own management tools and can store fairly significant volumes of data without any issues. Any database is only as efficient and as good as it is designed, so consider learning "Third Normal Form" database design.
HAPPY BOY
2016-06-16 11:04:25 UTC
PHP=presentation/user interaction

MySql/Sql=data storage

+

Webserver(Apache/Glassfish)=Running PHP.
Daniel B
2016-06-16 08:44:28 UTC
PHP is a server side language used to create dynamic web sites, site that are not just static HTML files. SQL is a language used to query relational databases and variations of it are supported my most relational database servers. MySQL is an free, open source database server.



So let's take Yahoo Answers and an example. You would have a web page that allows a person to enter a question. The question would get posted back to a PHP page that would take the question and using an SQL statement, write it to a database like MySQL. When another users goes to a page to see all the questions, the PHP page would generate an SQL query to read the appropriate questions from the database and then would dynamically build that HTML that displays the list of questions. This is a over-simplification but it gives you an idea of how things work.
Chris
2016-06-16 08:21:14 UTC
PHP is mostly used to create dynamic websites.



When you have a static website and a user requests a resource (by going to site.com in a browser), the basic webserver running on site.com will simply send back the file (in this default case: index.html), which is then displayed by the user's browser.



PHP allows you to intercept this request and do stuff on the server, which usually means that the returned document is created on the fly (which is what "dynamic" website refers to).



Here's a VERY simply example:




echo rand(1, 6);



If you save those two lines as "index.php" on a PHP-enabled webserver, the user will end up seeing a number from 1 to 6 in their browser.



Refreshing the page will re-run the php script, generating a different random number, which is then sent back to the user.



You can freely mix HTML and php:



You roll the die:





PHP will output the first HTML part 1:1, then the random number, then

.



So a user visiting the domain will get something like

You roll the die: 3







mySQL is just (EDIT) an implementation of SQL. It's a database server which stores databases. Those consist of tables, which store rows of data. Think of it like lots of Excel spreadsheets.

PHP allows you to open a connection to the mySQL server and request or insert/update data.





If you want to try out PHP,

- get xampp: https://www.apachefriends.org/index.html

- get the PHP version of Netbeans: https://netbeans.org/downloads/



Installing xampp will turn your computer into a php server, and you can visit your pages by going to http://localhost/folder
Dave
2016-06-16 07:54:39 UTC
PHP is a language. SQL and MySQL are database servers.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...