I am new in PHP/Mysql. I want to input sth from website to mysql, then output the formatted data to .txt, and finally use Excel to open the .txt file. I believe there are better and simpler ways than what I did. But I want to know what's wrong in my codes. Here are the details:
In survey.html, I need people input their ID and comment.
In Mysql, I've already made the survey table.
I use survey_result.p hp to import people's input...
User Profile
Collapse
-
How can I format-output data from Mysql to a file?-relatively long
-
I tested. It is nothing to do with where functions declared. I think I did exactly as
the code provided. Here are first part of my code and the error message:
Code: ( c )
#include <stdio.h>
void main ()
{
int max;
int a[10], i;
printf ("enter total number: ");
scanf ("%d", &max);
const int maxmium =... -
I think this may be the problem:
I define all the functions; then a number is inputted and it is defined as a constant (say, y, using the code that weaknessforcats posted); after that, the functions are called.
I guess the functions should be defined after the constant is defined, because come of them use the constant (y).
I'll try this soon......Leave a comment:
-
-
A simple question about input a constant in C
I want to input (scanf) an integer, then treat (or define) it as a constant. How do I do? -
I find a way to write data into the array. Now the problem is since the numbers of elements are not same in different cell, when printf %c, some strange characters may appear.
[code=c]
#include <stdio.h>
#include <stdlib.h>
void main( )
{
char out_char;
char array[3][2][5];
int i, j, k;
FILE *pfile = NULL;
char *filename = "data.prn";...Last edited by AdrianH; Jun 10 '07, 07:38 PM. Reason: Please use [code=c][/code] to increase readability!Leave a comment:
-
read data from file, write into 3D array - need help again.
Thanks in advance. This program is written in C.
It needs to read all characters from a file; then write them into a 3D array (yes, 3D!).
The file is a .prn file (one of the Excel types), which separates columns with space.
To simplify the question, the file contains 3 rows and 2 columns:
abc 2,3
defg 4
h 5,6
array is array[3][2][5], where the 3rd D contains the # of rows; 2nd D has...Last edited by AdrianH; Jun 10 '07, 07:37 PM. Reason: Please use [code=c][/code] to increase readability! -
With the help and hints I got from here, I figure it out!
The key is array of pointers needs to be used instead of pointer to array.
I tested the following code. It works. Note that it is not necessary to initiate int i=0;
Many thanks to Savage and AdrianH!
[code=c] int i, k;
char str[4][6]={"adevf", "dcdhn", "oledc", "brdca"};
char chr[3]={'a', 'b', 'c'};...Last edited by AdrianH; Jun 6 '07, 12:44 PM. Reason: Change to use [code=c][/code] tags to improve readability.Leave a comment:
-
Thanks!
line 10 gets the results of strchr, putting them in that two dimensional array. I think the problem is the pointer in line 10. But I don't know how to solve it.
I think i is initialized, see line 1. (is it right?)...Leave a comment:
-
question about pointers in a 2-D array and strchr
four strings are in a 2-D array; use strchr to find characters a, b, c, respectively;
search results are to be put in another 2-D arrray ter[ ][ ]:
results of searching 'a' in the 1st string go to ter[0][0], 'b' to ter[0][1]...
... 2nd string to to ter [1][0], 'b' to ter[1][1]...
...
here are the codes:
...
[code=c] int i, k;
char str[4][6]={"adevf",...Last edited by AdrianH; Jun 5 '07, 06:30 PM. Reason: Please use [code=c][/code] tags for improved reability. -
Thank you very much!
Not only did you answer this extension question, but also answered those related to my previous questions!...Leave a comment:
-
-
How to add an extension to an input filename?
Read from an existing file, then output a file with the same name but an extension:
file = raw_input ('Enter the filename:\n')
fileout = open ('file.out', 'w')
However, when I enter a filename like "test", it gives the output file as "file.out" instead of "test.out". -
Among the solutions, this looks like the simplest and most efficient one.
The only problem is that the output includes some symbols. For example:
the 1st row is
['01\n', '03\n', '05\n']
Since I deal with numbers, I first convert them to int or float, then the output is what I want now:
01 03 05
Although I still don't know how it works if them are strings.
Thanks a lot!!!...Leave a comment:
-
The first one works - it seperates odd and even lines. However, the odd_lines in the output are not in one row; so are the even_lines....Leave a comment:
-
I tried the 1st one. It worked when using ...open('file') : in line 2.
But I have a further question:
How does this work:
read the 1st, 3rd ... lines, then output them in the 1st row (seperated by space);
read the 2nd, 4th ... lines, output in the 2nd row;
...
I used several loops. None of them worked....Leave a comment:
-
need help in output table
want to read selected lines in a file, then output in one row.
For example:
read the 1st, 3rd ... lines, then output them in the 1st row;
read the 2nd, 4th ... lines, output in the 2nd row;
...
I used several loops. None of them worked.
Thanks.
No activity results to display
Show More
Leave a comment: