How do I display whatever that gets submitted in a CSV File on an HTML Web Page by pulling it with php... I am kind of lost....?

Recommended Answers

@<MICHAEL>

How do I display whatever that gets submitted in a CSV File on an HTML Web Page by pulling it with php... I am kind of lost....?

You know it be nice if you can once in a while click Mark Solve on some of the threads …

Jump to Post

@<MICHAEL>

Yes, that correct that will echo or print the table on the website.

You can try this website:

http://www.internoetics.com/2011/05/16/working-with-csv-text-files-php/

or use this too:

http://phpmaster.com/5-inspiring-and-useful-php-snippets/

It has some examples that will …

Jump to Post

All 8 Replies

Member Avatar

@<MICHAEL>

How do I display whatever that gets submitted in a CSV File on an HTML Web Page by pulling it with php... I am kind of lost....?

You know it be nice if you can once in a while click Mark Solve on some of the threads you posted. It's just that sometimes you just double a same questions because you can't add something or can't modify it.

You need to used this function:

http://us3.php.net/manual/en/function.fgetcsv.php

to pull the csv file on to the webpage.

I'm sorry, I understand that I tend to forget to hit the mark solved button... I will make a moment to add a few mark solved articles... but some of those are still open and need answering...

So, through that link... i should use this?:

<?php
$row = 1;
if (($handle = fopen("test.csv", "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $num = count($data);
        echo "<p> $num fields in line $row: <br /></p>\n";
        $row++;
        for ($c=0; $c < $num; $c++) {
            echo $data[$c] . "<br />\n";
        }
    }
    fclose($handle);
}
?>

Thanks for your response

Well... I got it to work but when I placed numbering on it... it counted oddly... It counted: 1 2 4 6 9 12 15 and so on... I am going to investigate this and come back to zthis thread...

*this...

I spelled "this" wrong...

Member Avatar

@<MICHAEL>

Well... I got it to work but when I placed numbering on it... it counted oddly... It counted: 1 2 4 6 9 12 15 and so on... I am going to investigate this and come back to zthis thread.

OK, that's neat you got it working. The odd number might have to do with the cvs file. Did you put this 0; in front of all your data:

0;Posting;a
1;Whiz;s

I had this... but this could be what you mean by having a 0...

$tdcount = 0;

This is just a variable... but it may not mean much...

Member Avatar

@<MICHAEL>

$tdcount = 0;

No, that's not what I meant. I'm not quite sure where you got that code? You know you post a lot of threads. It's bit hard to remember what code you post or someone post a code on your thread.

Post the code so I can see what you are doing.

Read this:

Basic rules and examples

http://en.wikipedia.org/wiki/Comma-separated_values

it will show an example what I mention.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.