SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2009
    Location
    Wenatchee, WA
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Incorporating quotes from a flat file into a side-bar

    Hello,

    I want to use some appropriate quotes (think 'Quotable Quotes' or something like that) in a side bar area of my website. At the moment I pretty much have a flat text file with a few dozen quotes copied off various quote sites on the 'Net. Most are quotes of public figures, so not exactly proprietary. I wanted to insert one or two randomly selected quotes into this sidebar area on any given page on the site each time its loaded. The site is not a high-traffic one, so I'm not looking for any sort of industrial grade solution - plus I'm fairly green here, in case you hadn't noticed

    At this point, I kind of have an idea of what I want it to look like in the end, but only a vague inkling of how to make it happen. I've gathered that something like PHP+MySQL would probably be able to do exactly what I want, but it seems like using a sledgehammer to drive tacks with, doesn't it? I'm not saying I wouldn't be interested in trying it at some point (just to learn PHP/MySQL if nothing else) but are there other, simpler ways to go about this? Any that just use HTML/CSS?

    TIA,

    Monte

  2. #2
    SitePoint Wizard bronze trophy Tailslide's Avatar
    Join Date
    Feb 2006
    Location
    Bedford, UK
    Posts
    1,687
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Personally I'd stick the quotes into a text file - one quote per line - and then use PHP to randomly display one quote each time the page is refreshed.

    So in your page you'd have:

    HTML Code:
              <blockquote>
               <?
               $fc = join("",file("quotes.txt"));
               $fc = "$fc\n"; $spl = split("\n",$fc);
               srand((double)microtime()*1000000);
               $rndnum = (rand()%(count($spl)-1));
               echo $spl[$rndnum];
               ?>
               </blockquote>
    And in quotes.txt you'd have:

    HTML Code:
    <p>Blah blah blah blah<cite>Someone Interesting</cite></p>
    <p>Blah blah blah blah blah blah<cite>Someone Else Interesting</cite></p>
    etc etc

    Then you can use your CSS to style the blockquotes and cite etc as you want - e.g. with big quote marks.
    Little Blue Plane Web Design
    Blood, Sweat & Rust - A Land Rover restoration project


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •