使用 PHP MySQL PHP 从数据库中获取数据时遇到问题 [英] Having problem in fetching data from database using PHP MySQL PHP

查看:61
本文介绍了使用 PHP MySQL PHP 从数据库中获取数据时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经按照示例尝试了一个非常简单的 PHP MySQL Ajax 示例 -

I have tried a very simple example of PHP MySQL Ajax following the example -

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

我创建了两个文件,将它们放在同一个文件夹中并将其上传到服务器.我还检查了 php 文件中与 DB 的连接.但我不明白为什么 html 文件没有从数据库中带来任何数据.那有什么问题.我遵循的例子可以在这里找到.

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. But I don't understand why the html file does not bring any data from the the database. What's wrong with that. The example i followed can be found here.

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

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

我对 AJAX 非常陌生,真的不明白发生了什么.任何形式的帮助将不胜感激.

I'm very new in AJAX and really don't understand what's going on. Any sort of help will be appreciated.

推荐答案

我的 2 美分:首先,尝试一个 更简单的 Ajax 请求,让自己熟悉事物的机制.

My 2 cents: First of all, try a simpler Ajax request to get yourself used to the mechanics of the thing.

在 PHP 端你要做的就是 echo 输出一些数据.例如,你可以让你的 ajax 打开test.php",然后让test.php"看起来像这样:

All you have to do on the PHP side is echo out some data. For example, you could have your ajax open "test.php", then have "test.php" look like this:

<?php echo "working"; ?>

然后,只需提醒 yourRequest.responseText(响应文本属性),它应该说工作".

Then, just alert yourRequest.responseText (the response text property) and it should say "working".

顺利完成后,您可以修改 PHP 文件以发出 MySQL 请求.

Once you've got this moving smoothly, you can modify the PHP file to make a MySQL request.

这篇关于使用 PHP MySQL PHP 从数据库中获取数据时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆