从MySQL数据库中检索与jQuery,AJAX和PHP数据

编程入门 行业动态 更新时间:2024-10-23 14:31:39
本文介绍了从MySQL数据库中检索与jQuery,AJAX和PHP数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图找出如何使用AJAX调用到PHP页面MySQL数据库检索数据。我一直跟着教程

I am trying to figure out how to retrieve data from a MySQL database using an AJAX call to a PHP page. I have been following this tutorial

www.ryancoughlin / 2008/11/04 /使用-的jQuery到提交表单/

但我无法弄清楚如何得到它发回JSON数据,这样我可以阅读。

But i cant figure out how to get it to send back json data so that i can read it.

现在,我有这样的事情:

Right now I have something like this:

$('h1').click(function() { $.ajax({ type:"POST", url: "ajax.php", data: "code="+ code, datatype: "xml", success: function() { $(xml).find('site').each(function(){ //do something }); }); });

我的PHP我想会是这样

My PHP i guess will be something like this

<?php include ("../../inc/config.inc.php"); // CLIENT INFORMATION $code = htmlspecialchars(trim($_POST['lname'])); $addClient = "select * from news where code=$code"; mysql_query($addClient) or die(mysql_error()); ?>

本教程只展示了如何将数据插入一个表格,但我需要读取数据。任何人都可以点我在往好的方向发展?

This tutorial only shows how to insert data into a table but i need to read data. Can anyone point me in a good direction?

谢谢

克雷格

推荐答案

这是没有什么不同。还是做你的东西在ajax.php获取数据,通常是我们做的。和发送响应你的货柜页面上。

It's nothing different. Just do your stuff for fetching data in ajax.php as usually we do. and send response in your container on page.

喜欢这里解释的:

openenergymonitor/emon/node/107

www.electrictoolbox/json-data-jquery-php-mysql/

更多推荐

从MySQL数据库中检索与jQuery,AJAX和PHP数据

本文发布于:2023-10-27 15:40:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1533810.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库中   数据   MySQL   jQuery   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!