Results 1 to 9 of 9

Thread: Specific Text selection

  1. #1
    Join Date
    Mar 2012

    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
    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.


  3. #3
    Join Date
    Feb 2012
    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

    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
    For month based information the XML file can have the following schema.

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

  6. #6
    Join Date
    Jun 2008
    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:

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

    PHP Code:


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

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

  7. #7
    Join Date
    Mar 2012

    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
    simply place the code in your <div> tag. The <?php and ?> specify the php code.

  9. #9
    Join Date
    Mar 2012


    Again, thank you.

    I have tried that, but the code does not seem to be working. I copied and pasted (changing file names and directories) and even tried just typing it in again, but all I get in my div is the actual code.

    I typed it in to a new php file, and it worked all good. This is the code for that part of the page:
    <div id="apDiv17">

    $today = date ( m/d );

    $xmlDoc = new DOMDocument ();
    $xmlDoc->load ( "Reading/readings1.xml" );

    $readings = $xmlDoc->getElementsByTagNameNS( "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>";

    Does anything in there look wrong?


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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.19602 seconds
  • Memory Usage 2,933KB
  • Queries Executed 15 (?)
More Information
Template Usage (35):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (9)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (73):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates