MySQL-How to get the data inside the database in PHP and call it in the HTML specified location, displayed on the page (Wamp environment)

Source: Internet
Author: User
Tags learn php
    1. There is an input in the HTML to display the data retrieved from the backend.

    2. PHP files from the database to get the data operation also understand

Now is not quite understand the whole process of interaction is what ~

Reply content:

    1. There is an input in the HTML to display the data retrieved from the backend.

    2. PHP files from the database to get the data operation also understand

Now is not quite understand the whole process of interaction is what ~

Using the framework will help you assign an address to the MVC and then display it without using the framework to nest back-end data requests directly on an HTML page and then populate to input

Code

  
     None Title Document  
    
     
    
     
    
    
    !--? php$link=mysql_connect (' localhost ', ' root ', ' 123 ') or Die ("database connection Failed");//Connection Database mysql_select_db (' Lyb ', $link);// Select Database mysql_query ("Set names UTF8");//Set Encoding format $q= "SELECT * from Content";//Set Query instruction $result=mysql_query ($q);//Execute Query while ($ ROW=MYSQL_FETCH_ASSOC ($result))//The result result set query results in a {echo " 
     
       ";}? > 
     
message content
number user title content publish time
". $row ["id"]. " . $row ["username"]. " . $row ["title"]. " . $row ["Content"]. " . $row ["Lastdate"]. "
return

First of all, according to our demand, there are two ways to achieve!

1. As a wamp environment, beginners to learn PHP backend novice, we first look at the Php+html Hybrid implementation method:

index.php File Contents:


  
   
  
   测试PHP+HTML混合
  
   

2. As a back-end PHP, many times we need to integrate data to the front-end, after learning JavaScript, we can take the asynchronous interactive way from the backend to get query results updated to the input input domain.
In the project we usually implement in the latter way.

For more information, these keywords are available for your reference:

Javascript
ajax
js异步交互
You can use the JQuery library to experience better JavaScript hack processes.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.