www.webdeveloper.com
Results 1 to 9 of 9

Thread: Specific Text selection

Hybrid View

  1. #1
    Join Date
    Mar 2012
    Posts
    4

    Red face Specific Text selection

    Hi guys,

    I'm sorry if this is covered in a previous thread, but I couldn't see it while I skimmed through.

    I am brand new to self developed sites (ie: I have never had to code my self before, using only the likes of wordpress and joomla!).

    I am desiging a site for a church that requires a daily Bible reading schedule to be put up. I have a .txt file that lists the applicable daily readings, with each day on a separate line, but don't know how to code PHP to make it happen.

    Is there anyone out there who can assist me?

  2. #2
    Join Date
    Jun 2008
    Posts
    35
    What exactly do you want to do with the daily readings?

    Do you want to display them in a html table, import them to a database, upload the .txt file to your website.

    Please provide a little more information so that I may help.

    Thanks

  3. #3
    Join Date
    Feb 2012
    Location
    youTUBE
    Posts
    234
    Use an XML file to hold your data, rather than a text file. You have various options from that point on. You can have your page look for an XML file with a date on it, like: "dailyReading20120401.xml", if the readings differ from week to week. If the daily readings are fixed then the xml file could contain a Monday, Friday, Sunday section.

    If you wish to send the daily readings with the page you can use php to access the XML file and read the appropriate section in an ordered way.

  4. #4
    Join Date
    Mar 2012
    Posts
    4

    In Reply

    Hi guys,

    Thanks for the replys.

    The text will be displayed in a div box. All I need it to do is select the correct line of text to display according to the day of the week. I have a random text selector (in PHP) that will select a line of text from a .txt file to display in a similar fashion, but for this particular item I obviously want it to take it in the correct order, not random.

    I am definatley open to advise, so if an xml file is a better option, I will run with that- but the scripting to get the correct line is where I am now stuck. If date is a bad option (I don't need year, just month and day) I can number each line 1-365 if that would work better?

    Thanks for your help!

  5. #5
    Join Date
    Feb 2012
    Location
    youTUBE
    Posts
    234
    For month based information the XML file can have the following schema.

    Code:
     
    <?xml version="1.0" encoding="UTF-8"?>
    <index>
    <March>
      <Monday>
       <reading>11:30AM :: John the Baptist</reading>
       <reading>19:30PM :: Father Scroll</reading>
      </Monday>
     
      <Saturday>
       <reading>11:30AM :: John the Baptist</reading>
      </Saturday>
    </March>
     
    <December>
      <Christmas day>
        <reading>19:30PM :: The Holy Spirit</reading>
      </Christmas day>
    </December>
     
    <index>

  6. #6
    Join Date
    Jun 2008
    Posts
    35
    I agree that xml is probably a better way of doing things.

    If you use an xml format like in a file called readings.xml:

    Code:
    <?xml version="1.0"?>
    <Readings>
        <Reading date="2012/03/17" reader="John Smith">John The Baptist</Reading>
        <Reading date="2012/03/18" reader="Fred Bloggs">The Holy Spirit</Reading>
    </Readings>
    then the following code would show all the readings for today's date:

    PHP Code:
    <?php

    $today 
    date('Y/m/d');

    $xmlDoc = new DOMDocument();
    $xmlDoc->load'readings.xml' );

    $readings $xmlDoc->getElementsByTagName('Reading');
    if (
    $readings) {
        foreach (
    $readings as $reading) {
            
    $date $reading->getAttribute('date');
            if (
    $date == $today) {
                echo 
    $passage $reading->nodeValue;
                echo 
    " to be read by ".$reading->getAttribute('reader')."<br />";
            }
        }
    }
    ?>

  7. #7
    Join Date
    Mar 2012
    Posts
    4

    Red face Thanks, just a little more help please!

    Thanks for the scripts.

    I have been looking at this, but as I said earlier, I am a total newbie at this.

    What is the best way for me to include this script in the site. Do I put that script directly into the <div> tag? or reference to it as a < script > tag?

    I thank you for the education. I hope to be able to pass on the goodwill when I have learned some!

  8. #8
    Join Date
    Jun 2008
    Posts
    35
    simply place the code in your <div> tag. The <?php and ?> specify the php code.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles