Jump to content

Archived

This topic is now archived and is closed to further replies.

rawky

What am I being asked to do?

Recommended Posts

Hello all

I am very VERY new at PHP and have been asked to produce some kind of a form page using PHP as part of my course. Now im not trying to skive my way through it by asking someone to do the work for me its just i cant actually understand what im being asked!!! if someone out there could take a look at this description my lecturer has given me and translate it for me that'd be fantastic. Hopefully someone will be able to! :D

Here goes:

"second php/xhtml project due: produce a php webpage that has a form with a text field; it accepts a URL which points at another file, which contains several other URLs, one on each line. The goal is to produce a table, each element of which contains the contents of those other URLs. The number of elements in each row of the table should also be submitted via the form.

Start off by assuming that each of the files contains plaintext; then detect images and html files as well. [There are various ways to get the suffix of a URL; one is to explode the URL on "." and look at the last element of the array.] You might want the trim() function to get rid of whitespace at each end of the URLs. Create your tables without using for loops, foreach loops, while loops or repeat loops. That is, do it all with functions. Note that when embedding html pages inside a table, you only want to display the body; that is, you want to get rid of everything before the "<body>" tag. An easy way to do this is to explode the page contents using "<body>" as the separator.
The contents of the pages are up to you, but remember other people may look at it. Make sure the page is xhtml-validated.

Submit the full URL webpage addresses to NESS. These should include the overall php page, both in the departmental webspace and your university space, and the individual files, saved as .txt files (in either webspace) so I can look at the source with a browser. "


Here's hoping!!

Martin

Share this post


Link to post
Share on other sites
My interpretation would be as follows.

On your server you have a file called, say, "myfile.txt" which contains something like

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]my.domain.com/path/fileA.txt
my.domain.com/path/fileB.txt
my.domain.com/path/fileC.txt[/quote]

You have to create a form in which you would enter the url of "myfile.txt" plus a number to indicate how many elements on each row (more later)

You process the form data, picking up the filename and open the file.

You then have to get the contents of each of those file (fileA, FileB) etc and display them in a table

[code]+-------------------------------+
|  FileA.txt                    |
+-------------------------------+
|  Contents of fileA            |
|                               |
+-------------------------------+
|  FileB.txt                    |
+-------------------------------+
|  Contents of fileB            |
|                               |
+-------------------------------+
|  FileC.txt                    |
+-------------------------------+
|  Contents of fileC            |
|                               |
+-------------------------------+[/code]

I think the number entered on the form is to define a layout like this (number = 2)

[code]+-------------------------+--------------------------+
|  FileA.txt              |  FileB.txt               |
+-------------------------+--------------------------+
|  Contents of fileA      |  Contents of fileB       |
|                         |                          |
+-------------------------+--------------------------+
|  FileC.txt              |
+-------------------------+
|  Contents of fileC      |
|                         |
+-------------------------+[/code]



The next step is try it when "myfile.txt" contains something like

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]my.domain.com/path/fileA.txt
my.domain.com/path/fileB.html
my.domain.com/path/fileC.jpg[/quote]

I cannot understand not being able to use loops but use functions instead. Why must the two be mutually exclusive?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.