weixin_33693070 2012-06-12 04:16 采纳率: 0%
浏览 31

jQuery加载MySQL Fetch数组

I'm a beginner in jQuery area and I have simple question like this :

I want to load (AJAX) MySQL result in array, let's say :

$row[0] = first name
$row[1] = last name
$row[2] = phone number

I have no problem with PHP part, but I have difficulties to display each of that array content on different id. because syntax I found loads everything processed by PHP :

<script type="text/javascript">
$(document).ready(function(){
    $('#mysql-result').load('ajax.php');
});
</script>

how to get 'First Name', 'Last Name' and 'Phone Number' from PHP with only one time load and still I can put the result in different . thank you.

UPDATE

I give you real example about what I need. Here's my HTML file named ajax.html :

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Ajax Trial</title>
</head>

<body>
<div id = "fistname"><!-- ajax result goes here --></div> 
<div id = "lastname"><!-- ajax result goes here --></div>
<div id = "phonenumber"><!-- ajax result goes here --></div>
</body>
</html>

and here's my PHP file, named ajax.php :

<?php
require_once 'config-min.php';
$con = mysql_connect($DbServer,$DbUser,$DbPassword);
mysql_select_db($DbName, $con);

$result = mysql_query("SELECT FirstName, LastName, PhoneNumber FROM User WHERE ID = '201' LIMIT 1");
$row = mysql_fetch_array($result);

echo $row[0];
echo $row[1];
echo $row[2];

mysql_close($con);
?>

now, my question still same... how to get this PHP result (3 echos), load once, then displayed in those 3 different divs

  • 写回答

2条回答 默认 最新

  • weixin_33690367 2012-06-12 04:24
    关注

    Have you tried adding to your php code:

    echo $firstname.' '.$lastname.' '.$phonenumber;

    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)