简体   繁体   English

在HTML网页中显示SQL查询结果

[英]Display SQL Query Result in a HTML Webpage

I'm comfortable with PHP/SQL, however my experience with HTML and web development in general is limited. 我对PHP / SQL感到满意,但是总体而言,我在HTML和Web开发方面的经验有限。

I need to display the results of a SQL query in a simple HTML webpage. 我需要在一个简单的HTML网页中显示SQL查询的结果。 I understand this can be done by embedding some PHP code in the HTML document, using <?php.......?> 我知道可以通过使用<?php.......?>将一些PHP代码嵌入HTML文档中来实现<?php.......?>

However my current PHP code contains sensitive login details for my database, and obviously this couldn't be included... 但是,我当前的PHP代码包含我数据库的敏感登录详细信息,显然这不能包括在内。

What's the best approach to doing this? 最好的方法是什么?

You can use a mvc framework, like yii or codeigniter.. so you don't need to insert that data in the view files, u just have that in configuration files, which is in another folder.. 您可以使用yii或codeigniter之类的mvc框架。因此,您无需在视图文件中插入该数据,只需将其保存在另一个文件夹中的配置文件中即可。

hope it helps 希望能帮助到你

Well, the appache server pre-processes you .php file, parsing the php code and replacing it by what it should return, so if you do not echo sensitive details, you will don't have problems :) 好吧,appache服务器会对您的.php文件进行预处理,解析php代码并将其替换为应该返回的内容,因此,如果您不回显敏感的细节,您将不会遇到问题:)

There is an image will maybe help you to understand : How it works 有一张图片可能会帮助您了解: 它是如何工作的

Well, now you have to understand that Appache will never return itslef the content of the php of your webpage, if it's well configurated, and if you didn't let exploits like free url including (see in php.ini : allow url include or something like that ;) ) 好吧,现在您必须了解,Appache不会对其网页php的内容进行正确配置,并且如果您不让其使用诸如免费url在内的漏洞(请参阅php.ini:请允许url包括或那样的东西;))

I'm talking about apache, but there is other web servers, nginx etc ... 我说的是Apache,但是还有其他Web服务器,nginx等...

For the displaying of your results, i suggest you print_r() or var_dump(). 为了显示结果,我建议您使用print_r()或var_dump()。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM