0

I have one csv file separated by the following character |. The file has three columns; one is the url(COL1), the other is a small text(COL3), and the last one its an image location(COL2). I need a script that gives me the html code like this with the data from the csv file:

<a href="COL1"><IMG SRC="COL2" />COL3</a>

How can I do this?

1
  • which serverside language do you have? Commented Oct 2, 2012 at 21:18

1 Answer 1

0

You using a serverside language, I'm assuming? With php, you'd be after fgetcsv.
Here's one example: How to import csv file in PHP?


UPDATED:

Try this:

$separation_char = "|"; // character separating fields
$filename = "test.csv";

$row = 1;
if (($handle = fopen($filename, "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, $separation_char)) !== FALSE) {
        echo '<a href="' . $data[0] . '"><IMG SRC="' . $data[1] . '" />' . $data[2] . '</a>';
    }
    fclose($handle);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.