简体   繁体   English

使用PHP MySQL PHP从数据库中获取数据时遇到问题

[英]Having problem in fetching data from database using PHP MySQL PHP

I have tried a very simple example of PHP MySQL Ajax following the example - 我在该示例之后尝试了一个非常简单的PHP MySQL Ajax示例-

http://www.tutorialspoint.com/ajax/ajax_in_action.htm http://www.tutorialspoint.com/ajax/ajax_in_action.htm

I created two files putting these in a same folder and uploaded it to the server.I have also checked the connection with DB from the php file. 我创建了两个文件,并将它们放在同一文件夹中,然后将其上传到服务器。我还从php文件中检查了与DB的连接。 But I don't understand why the html file does not bring any data from the the database. 但是我不明白为什么html文件不带数据库中的任何数据。 What's wrong with that. 怎么了 The example i followed can be found here. 我遵循的示例可以在这里找到。

http://aiworker2.usask.ca/age/ajax.html http://aiworker2.usask.ca/age/ajax-example.php http://aiworker2.usask.ca/age/ajax.html http://aiworker2.usask.ca/age/ajax-example.php

I'm very new in AJAX and really don't understand what's going on. 我是AJAX的新手,真的不了解发生了什么。 Any sort of help will be appreciated. 任何帮助将不胜感激。

My 2 cents: First of all, try a simpler Ajax request to get yourself used to the mechanics of the thing. 我的2分钱:首先,尝试一个更简单的Ajax请求,以使自己熟悉事物的原理。

All you have to do on the PHP side is echo out some data. 在PHP方面,您要做的就是echo一些数据。 For example, you could have your ajax open "test.php", then have "test.php" look like this: 例如,您可以将ajax打开“ test.php”,然后将“ test.php”显示如下:

<?php echo "working"; ?>

Then, just alert yourRequest.responseText (the response text property) and it should say "working". 然后,只需警告yourRequest.responseText (响应文本属性),它应该显示“正在工作”。

Once you've got this moving smoothly, you can modify the PHP file to make a MySQL request. 一旦顺利进行,就可以修改PHP文件以发出MySQL请求。

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

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