How to return data to html after php queries the database
辉€
辉€ 2018-11-08 20:59:52
0
5
2431
html
<!DOCTYPE html><html lang="en"><head>
    <meta charset="UTF-8">
    <title>Title</title></head><body><table border="1">
    <tr>
        <td>
            <?php
                echo$a;   #百度说这样可以,但我总是失败
            ?>
        </td>
    </tr></table></body></html>
php
<?php省略数据库查询;
$a = 123;?>

There is another situation

html
<!DOCTYPE html><html><head>
    <meta charset="UTF-8">
    <title>Title</title></head><body>
     <form>
     <input type="text">
     <input type="submit">   #代码简写了
     </form>
    </body></html>
    
php
<?php
省略数据库查询;
$a = 123;?>

I don’t know PHP, but I suddenly need to use it.

How to display the returned value in html after php queries the database.

After searching Baidu for a long time, I found that it didn’t work. .


We have reached the point where the ajax method is feasible. But if it is written in <script>, you can see it by directly viewing the code in the browser. How can I hide similar scripts and also achieve html php interaction?


What methods are you using now to implement html php interaction?

Thank you

辉€
辉€

reply all(4)
虔

Write a tpl file with a suffix name, then this tpl file is equivalent to an html file with a suffix name. Use PHP's object-oriented method to parse through regular expressions, and use PHP's caching mechanism to implement code that can be implemented without refreshing the browser. Data updates.

  • reply For example, {$name}, PHP's built-in variables in the HTML page are injected into _add("name", "Hello, PHP"). At this time, the HTML page will have the value of the injected PHP variable.
    author 2018-11-13 00:14:59
天忆

When writing php code in an html file, you need to change the file suffix to php, or add the html format to parsing in Apache, otherwise it will not be parsed.

神沐

1541732566(1).jpg

# Just embed the php code in the html

胤彬-

It’s been a long time since I wrote this kind of mixed HTML and PHP.

Nowadays, the front-end and back-end are generally separated. The data queried by PHP is written out of the interface and returned in json form, and the front-end uses Ajax calls to obtain the data.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template