Forum Moderators: coopster & phranque

Message Too Old, No Replies

How to add content easily

I need a quick easy method

         

stickytape

1:26 pm on Jul 17, 2001 (gmt 0)



Afternoon all (morning to our American chums! :) )

Im (still) setting up a site for my university students in Manchester, England. The idea is that it's a site written FOR students, BY students, so that people can ask questions and get answers - keeping it interactive is the idea!

Anyways, your mission, should you choose to accept it is: I need to set up a way of people being able to personalise the way the content is displayed. What I need is, when someone clicks on a category, for example, "going out" all the news articles on "going out" are displayed but the rest are filtered out. I was kind of hoping to use PHP to do this and have looked for scripts (I can't write my own yet, but am trying to learn) but havent been able to find any. What I wanted really was to have a script that let me put something at the top of each report - such as Category="Going Out" and for a script to search for all of these and display them, when the "going out" category is selected.

Please, any ideas AT ALL are welcome. Cheers guys,

Rich

This message will self destruct in, errm... well, it wont really..... but you get the idea

sugarkane

5:05 pm on Jul 17, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How are you planning to store the reports? In seperate files?

If you stored each report for going out in a directory called, um lets see, 'goingout', then to output all those reports in PHP you'd use something like

<?
$dir=opendir("goingout");
while ($file=readdir($dir)) {
$foo=fopen("$dir/$file","r");
fpassthu($foo);
fclose($foo);
}
?>

Edit: Fixed daft syntax error!

(edited by: sugarkane at 7:07 pm (gmt) on July 17, 2001(edited by: sugarkane at 7:07 pm (gmt) on July 17, 2001

stickytape

6:51 pm on Jul 17, 2001 (gmt 0)



<--- a little confused. Thanks for the idea, but can you just clarify it for me.

For example, for a report I write it in a txt file called report1.txt and then for another report, it's report2.txt

I would store all these files in a folder "goingout/reports" Each report has a format such as the following...:

Bar Name: Sofa
Rating: 8/10
Report: REPORT GOES HERE

So, what I want, is for a script to be able to pull the bar name out of the report and put in the first row of a table. Then the rating put in the second row of a table and finally the report itself put in the third row of the table. The reason why I want to put them in different rows of tables is to apply different formatting to the text (i.e. the bar name will be bold, whereas the report itself wont be). If you think you can get around this some other way, then please tell me!

Thanks sugar for the script, I haven't tried it yet, but it looks nice and simple!

Is there an adaptation I can make to it to do the above?

Rich

sugarkane

7:23 pm on Jul 17, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The fpassthru() function basically just throws whatever is in the file onto the page at whatever point you call it in your PHP script, so the simplest way to get the effect you want would be to include html markup in the report file itself.

So, you'd have files called report1.html, report2.html etc in the 'goingout' folder, each one containing a snippet of html that would display the report in the way you want it.

stickytape

7:29 pm on Jul 17, 2001 (gmt 0)



Oh right cool....so basically, I wouldnt have the <body> or <head> tags etc etc.... just the plain sort of <class="bodytxt"> etc! Nice one, you're a genious

sugarkane

7:33 pm on Jul 17, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> just the plain sort of <class="bodytxt"> etc

Yup, exactly :)

stickytape

7:35 pm on Jul 17, 2001 (gmt 0)



you're the Daddy!