将原始数据转换为格式良好的行 [英] Convert raw data to well formed rows

查看:62
本文介绍了将原始数据转换为格式良好的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须创建一个数据网格,其中数据直接显示在数据库中。

我已经通过使用带有while循环的PHP脚本来完成它。即。它将继续从数据库中获取数组并逐个生成相应的行。

但是它的行数很少。随着每行的行数和大小的增加,它最终将成为一个巨大的HTML。


所以我想用javascript来添加行。所以我创建了一个函数,我将行字段作为参数传递给它,它会为表生成相应的行。


如果我通过键入它来手动调用它,该函数工作正常地址栏,但是当我在正文的 onload 上调用它时,它不会添加行...

我应该在哪里调用该函数?

展开 | 选择 | Wrap | 行号

解决方案

我解决了这个问题。


发布你的解决方案,万一有人有类似的问题。



发布您的解决方案以防有人遇到类似问题。



只需将表格留在需要显示数据的位置。

在PHP代码中...

[php]<?php

echo"

< body onload = \" insAllRws(); \">

< table class = \" grid\" id = \" table \">< / table>

< script type = \" text / javascript \">

函数insAllRws(){" ;;

while(


I have to make a data grid, in which data is shown directly from database.
I have done it by using PHP scripting with a while loop. ie. It would keep on fetching arrays from database and generate corresponding row one by one.
But with few rows its fine. As the number of rows and size of each row will increase, it will end up making it a huge HTML.

So I was thinking of using javascript to add rows. So I made a function to which I passed the row fields as arguments and it generates corrosponding row for the table.

The function is working fine if i call it manually by typing it in the address bar, but it is not adding rows when I call it on body''s onload...
Where should I call that function?

Expand|Select|Wrap|Line Numbers

解决方案

I solved the problem.


Post your solution in case someone has a similar problem.


Post your solution in case someone has a similar problem.

Just leave the table blank where you need to display the data.
In PHP code...
[php]<?php
echo "
<body onload=\"insAllRws();\">
<table class=\"grid\" id=\"table\"></table>
<script type=\"text/javascript\">
function insAllRws() {";
while(


这篇关于将原始数据转换为格式良好的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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