You appear to be programming in C so that's what this is... Here's a complete example where you can control the table formatting yourself. This is using sqlite3 calls and I made it produce a simple, complete HTML page. This is, of course, tied to your database due to the specific column names. It's more work to make it generic. But this should get you a lot closer to what you really want I hope.
Compile and run like this: myhtml t9_engine.db "select id,partnumber,pic from engine where id>7" > n.html #include <stdio.h> #include <stdlib.h> #include <string.h> #include "sqlite3.h" void checkrc(int rc,int check,sqlite3 *db) { if (rc != check) { fprintf(stderr,"%s\n",sqlite3_errmsg(db)); exit(1); } } void doMySQL(char *dbname, char *sql) { sqlite3 *db; int rc; sqlite3_stmt *stmt; rc=sqlite3_open(dbname,&db); checkrc(rc,SQLITE_OK,db); rc = sqlite3_prepare_v2(db,sql,strlen(sql),&stmt,NULL); checkrc(rc,SQLITE_OK,db); printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0//EN\"\n \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"); printf("<html>\n<head>\n<title>Parts List</title></head>"); printf("<body>\n"); printf("<table border=1>\n"); printf("<tr><th>ID</th><th>Part#</th><th>Picture</th></tr>\n"); while((rc=sqlite3_step(stmt))==SQLITE_ROW) { int id=sqlite3_column_int(stmt,0); printf("<tr>\n<td valign=top>%d</td>\n",id); char *partnumber = sqlite3_column_text(stmt,1); printf("<td valign=top>%s</td>\n",partnumber); char *pic = sqlite3_column_text(stmt,2); printf("<td><img src=\"%s\" height=220 alt=\"NOT FOUND:%s\"></td>\n",pic,pic); printf("</tr>\n"); } checkrc(rc,SQLITE_DONE,db); rc=sqlite3_finalize(stmt); checkrc(rc,SQLITE_OK,db); printf("</table>\n</body>\n</html>"); rc = sqlite3_close(db); checkrc(rc,SQLITE_OK,db); } int main(int argc, char *argv[]) { if (argc !=3) { fprintf(stderr,"Usage: %s database \"sql\"",argv[0]); exit(1); } doMySQL(argv[1],argv[2]); return 0; } Michael D. Black Senior Scientist Advanced Analytics Directorate Advanced GEOINT Solutions Operating Unit Northrop Grumman Information Systems ________________________________________ From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on behalf of YAN HONG YE [yanhong...@mpsa.com] Sent: Thursday, October 25, 2012 8:25 PM To: sqlite-users@sqlite.org Subject: EXT :[sqlite] FW: how to select " char in sqlite char bh1[320]; memset(bh1,0,320); strcpy(bh1,"sqlite3 -html -header t9_engine.db \"select id,partnumber,substr(\'<img src=\"\'||pic||\'\" height=220/>\',1,180) as img,pcs from engine where id>7;\" >> n.html"); system(bh1); //here couldn't work error: sqlite3 -html -header t9_engine.db "select id,partnumber,substr('<img src="'||pi c||'" height=220/>',1,180) as img,pcs from engine where id>7;" >> n.htmlError: n ear "'<img src='": syntax error 'pic' is not recognized as an internal or external command, operable program or batch file. The system cannot find the path specified. char bh1[320]; memset(bh1,0,320); strcpy(bh1,"sqlite3 -html -header t9_engine.db \"select id,partnumber,substr(\'<img src=\"\'||pic||\'\" height=220/>\',1,180) as img,pcs from engine where id>7;\" >> n.html"); strcpy(bh1,"sqlite3 -html -header t9_engine.db \"select id,partnumber,'<img src='||pic||' height=220/>' as img,pcs from engine where id>7;\" >> n.html"); system(bh1); //here could work the result is: <TR><TD>8</TD> <TD>AA34841687 000 INSONO-SOUS-MOTEUR--</TD> <TD><img src=C:\t9\images\INSONO-SOUS-MOTEUR.jpg height=220/></TD> //here I wanna add " char between 'C:\t9\images\INSONO-SOUS-MOTEUR.jpg' <TD>1</TD> </TR> and the best way is change < to < > to > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users