well I never, a+ did the trick!
I spent hours trying get it to work and I knew I must be close.
I settled on the following bit of code since it's nice and simple and seem's to do the trick ie prints out the HTML table with a unique ID.
sorry I forgot code tags , didn't think that my ity bity snitch of code deserved code tags!
file mode rt also works!
thanks for all the help. Here's the piece of code I'm using.
(with code tags...I hope) It takes input from a form and enters it into a HTML table. It's very simple but I can work it up to what I really need with time and effort.
Code:
void process2(char *s)
{
int ID=0;
int header_print =0;
char full_entry1[1000];
char name_first[300];
char name_last[300];
char test1_score[300];
char test2_score[300];
char test3_score[300];
char test4_score[300];
int linecount =0 ;
int inchar;
FILE *r ;
r = fopen(datafile,"rt");
if(r == NULL)
{
printf("%s%c%c\n", "Content-Type:text/html;charset=iso-8859-1",13,10);
printf("<P><EM>Unable to open data file</EM>");
}
while((inchar=fgetc(r))!=EOF)
{
if(inchar == '\n')
linecount++;
}
ID = linecount;
header_print=linecount;
if(header_print<1)
{
char b[] = "<TABLE> <TABLE BORDER >";
char d[] = "<TH> ID#";
char f[] = "<TH> LAST NAME";
char g[] = "<TH> FIRST NAME";
char h[] = "<TH> TEST 1 SCORE";
char i[] = "<TH> TEST 2 SCORE";
char c[] = "<TH> TEST 3 SCORE";
char j[] = "<TH> TEST 4 SCORE<TR>";
fprintf(r,"\n%s%s%s%s%s%s%s%s",b,d,g,f,h,i,c,j); // prints table headers
}
else
{
GetStringComponent("name_first", s, name_first);
GetStringComponent("name_last", s, name_last);
GetStringComponent("test1_score", s, test1_score);
//must execute once from here to print headers, ok then
fprintf(r, "\n<tr><td align=""center"" >%d<td>%s<td>%s<td><td>%s<tr>",ID,name_first,name_last,test1_score );
// doesn't work
fclose(r);
}
return;
}
hey, the tags worked.
Thanks all.