PHP Issue - Inserting Information from an Array - TechRepublic
Question
September 27, 2009 at 07:48 AM
dshanker

PHP Issue – Inserting Information from an Array

by dshanker . Updated 16 years, 9 months ago

I am trying to learn PHP in a way that works best for me (examining code, reverse engineering, etc.), but have hit a snag.

My objective is to enable my friend to change certain items (dates, prices, descriptions) on his site by filling in the “variables” (don’t know if that is a correct use of the term) on an “includes” file. I know there are cMS proggies, but they almost always use databases, are complex, and this seemed “simple” for my friend.

Anyway I used PHP to create standard parts, and the “content” sections changes from page to page.

Here is the “constants” file I set up [someone else did, I added session descrption for week


< ?php // ==== THIS PAGE IS TO UPDATE CERTAIN INFORMATION ON THE WEB PAGE ======= // ==== This DOES NOT APPLY to the Online Registration pages ===== ini_set('max_execution_time',0); //==== UPDATE COMMON WEB SITE CONSTANTS HERE ================== //Current Camp Year $yr_summer[0] = '2010 '; $yr_winter[1] = '2009-2010 '; //Session Dates $wk_dates[1] = 'July 5-8 '; $wk_dates[2] = 'July 12-15 '; $wk_dates[3] = 'July 19-22 '; $wk_dates[4] = 'July 26-29 '; $wk_dates[5] = 'August 2-5 '; $wk_dates[6] = 'August 9-12 '; $wk_dates[7] = 'August 16-19 '; $wk_dates[8] = 'August 23-26 '; //Session description for week and friday $wk_session[1] = 'Week 1 - July 5-8: Dribble/Ball Handling '; $wk_session[2] = 'Week 2 - July 12-15: Reps/Shooting '; $wk_session[3] = 'Week 3 - July 19-22: Offensive Moves '; $wk_session[4] = 'Week 4 - July 26-29: Dribble/Ball Handling '; $wk_session[5] = 'Week 5 - August 2-5: Shooting (Matt Brady Week) '; $wk_session[6] = 'Week 6 - August 9-12: Defense Week '; $wk_session[7] = 'Week 7 - August 16-19: 3-on-3 Week '; $wk_session[8] = 'Week 8 - August 23-26: Combo Week '; $fri_session[1] = '9:00 a.m.'; $fri_session[2] = '10:00 a.m.'; //DEFINE FEE & DISCOUNT $fee_for_1week = 110 ; //Fee for 1 week $fee_for_2week = 200 ; //Fee for 2 week $fee_for_3week = 270 ; //Fee for 3 week $fee_for_4week = 340 ; //Fee for 4 week $fee_for_5week = 400 ; //Fee for 5 week $fee_for_6week = 450 ; //Fee for 6 week $fee_for_7week = 490 ; //Fee for 7 week $fee_for_8week = 560 ; //Fee for 8 week $fee_friday_lesson = 30 ; //Fee for friday lesson per session $sibling_discount_rate = 10 ; //per child per week ?>

My problem is getting it into the web page.
Here is a snippet of code from the sbc_content.php section:

  • DRIBBLE/BALLHANDLING WEEK:
    July 5 to July 8

    Whether you are big or small. the handling of the ball is the most important factor in the game. It all starts here, and it starts with the dribble. And here is where you should start – from the ground up.

  • What I would LIKE to do is where it says:
    “July 5 – July 8”
    substitute code that calls the variable $wk_dates[1] from the updatefunctions.php file

    I insert the “sbc_content.php” file from the “main page” this way:



    <-td id="maincontent-index0">

    <-?php include "sbc_schedule.php"; ?->

    <-/-td->

    So basically what I need to know is how to call that variable in the particular spot now occupied by a hard/hand-coded date.

    I tried several different things — I am wondering if at least I got the “START” part correct to identify the file which holdes the info:


    < - ? ob_start(); include "common/updatefunction.php"; ? - >

    Any help on where to go from here? I have and issue with terminology, so that impairs my searching ability.

    This discussion is locked

    All Comments