开发板是TQ2440,linux系统
移植了boa,sqlite3,cgic
现在,应用程序每秒钟,将采集的数据如温度、湿度等,写入到数据库。
问题:用cgi,如何动态显示所产生的温度、湿度。【不要用刷新】
定时ajax调用你的cgi程序 我定时刷新的cgi程序如下:
#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>
int main()
{
sqlite3 *pdb=NULL;
sqlite3_stmt *stmt;
char *szErrMsg=0;
int rc,i;
rc=sqlite3_open("/home/dyh/date.db",&pdb);
if(rc)
{
fprintf(stderr,"can't open database: %s",sqlite3_errmsg(pdb));
sqlite3_close(pdb);
return -1;
}
printf("Content-type:text/html\n\n");
printf("<html>\n<head>\n<Meta http-equiv=\"Refresh\" Content=\"1;\"><title>test</title></head>\n<body>\n");
printf("<h1 align=\"center\">dongtai</h1>\n");
printf("<table border=\"1\" align=\"center\">\n");
printf("<tr>\n");
printf("<th>id</th><th>dev</th><th>wendu</th><th>time</th>\n");
printf("</tr>\n");
char sql[512];
//char *sql="select *from wsd where id=(select max(id)from wsd where dnum=1)";