PHP (or other) simple programming issue - advice?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • J-G
    Member
    • May 2004
    • 54

    #1

    PHP (or other) simple programming issue - advice?

    Question for ye programmers,

    My mission, should I shoose to accept it, is to reply to a friend who needs to know:
    "On a scale of 1 to 10, how easy/difficult is it to get a 'daily thought' from an Excel spreadsheet to a web page, so it changes daily?"

    *All* of my web customers have the "brochure-ware" type of website, i.e. they are non-dynamic, non-database-driven.
    I speak Access/VB, not MySQL/PHP; heck I've used tiny bits of Javascript, which may do the trick.

    What would you suggest (or charge? =^] )

    Thanks in advance from the rust belt USA,
    กกก Jess G. กกก
  • Amitabh
    Member
    • Mar 2004
    • 78

    #2
    Getting excel to work with PHP would be a difficult task, that too on Linux servers. You would be much better of reading simple text files or mysql, but that would require PHP knowledge.

    I don't think even javascript would be of any help here.

    Comment

    • J-G
      Member
      • May 2004
      • 54

      #3
      Understood;

      I understand; an Excel file would NOT go up on a web server. I would "dump" the Excel data into a text file or an array somewhere in a program.

      My backup plan was to install a Page Publisher-type of program (see it at http://www.interactivetools.com/products/pagepublisher/ for $99), then update the 'daily thought' that way, MANUALLY, from any site with web access.

      In my iiiiinnnnfiiinnniiiite spare time ...
      กกก Jess G. กกก

      Comment

      • sdjl
        Senior Member
        • Mar 2004
        • 502

        #4
        If you're using a later version of Excel, you could always dump the excel file down as an XML formatted document.
        That way, you could then parse the XML to get the content into a MySQL database or something of the sorts.

        Or, you could just parse the XML file and take a random tag value for the quote.
        It may work

        If you opted for the XML route, you can use the inbuilt PHP XML functions.

        David
        -----
        Do you fear the obsolescence of the metanarrative apparatus of legitimation?

        Comment

        • -Oz-
          Senior Member
          • Mar 2004
          • 545

          #5
          its easy, there are even javascript quote rotating scripts. Just goodle it. With javascript though you need to hand modify the script to add more quotes.

          On the other hand throwing it into a mysql data would allow for random pulling from the database. http://www.sitepoint.com has two tutorials on things like this.
          Dan Blomberg

          Comment

          • mattw
            Junior Member
            • Oct 2004
            • 2

            #6
            If the "daily thoughts" are in a simple text file (named "your_filename_here"), one "thought" per line, the following PHP would select one randomly and print it:

            PHP Code:
            <?php

                $daily_thoughts 
            explode("\n"file_get_contents('your_filename_here'));
                print 
            $daily_thoughts[rand(0count($daily_thoughts)-1)];

            ?>
            Of course, replace "your_filename_here" with the actual filename. Replace "\n" with whatever delimiter you want to use, if not a newline. The "rand(0, count($daily_thoughts)-1)" could be replaced with whatever function you want to use to select the thought (i.e. "date(j)" for day of the month, etc.)

            Comment

            Working...