0

Hi I have been trying to fix an annoying problem that I have currently got at the moment, I have a PHP page with normal text and some drop down boxes that display information from a database and I have some buttons using a ul and li attached to the drop down boxes I have a couple JavaScript functions that disable the second and third one until the the first two options are selected this is all working.

The problem I have got is I have a PHP variable that contains most of the HTML and text for the page and it is echoed out but i want to put the drop down boxes within this section but with the drop down boxes i need to have a include for my drop down boxes to work correctly but every time i try either the words include are echoed to the screen or it shows me a white page. This is my variable with the text in

$info = '<div id="Text">This page will guide you through how to create your own Careers in the Classroom presentation.
Producing a presentation is very simple, just follow the steps below: 
<ol>
1)  Choose an academic principle around which to base your answers
    <li>    This will determine in which lesson your presentation will be shown to pupils </li>
    <li>    First choose an academic subject from the drop-down box below (i.e. Maths, Science, Geography)</li>
    <li>    Then choose an area out of the subject you have chosen (i.e. Geometry, Physics, Physical Geography) </li>
    <li>    Which will then bring up a list of principles to choose from* (i.e. Area, Forces, Rocks)</li>
    *Make sure you pick the principle which is most relevant to your job because you will be asked to talk about it later*
</ol>


<<<<< this is where i want my drop down boxes to be >>>>

<br/><br/>
<ol>
    2)  Take note of your target age 
    <li>    Click the Show my target age button and take note</li>
    <li>    The principle you have chosen will be taken from a school curriculum which may apply to a variety of age ranges. Bear in mind that if you are preparing a presentation for a 16 year old pupil this will need to have a different tone to that aimed at an 8 year old pupil.</li>
    <div id="ResultList" >
        Click the button to find the key stage
    </div>
    <input style="position:relative;left:320px;top:-20px;" type="submit" value="Search"/>
</ol>
<ol>
    3)  Download the questionnaire 
    <li>    Below you will find a link to the questionnaire, it will be beneficial to read over this before you begin videoing. </li>
    <li>    The questionnaire is split into sections the most important section is D - Using school subjects in your career. </li>
    <li>    When answering the questions try to elaborate on your answers, the more information the better. </li>
    <li>    Where there is a choice of questions out of a section try to choose the ones which relate to your career the most or which yield surprising and interesting answers</li>
</ol>
<br/>
<ul style="width:140px;position:absolute;top:440px;height:25px;padding-top:1px;left:60px;list-style-type:none;" id="menu">
    <li style="list-style-type:none;">
        <a href=./downloads/questionaire.pdf>
            Questionnaire 
        </a>
    </li>
</ul>
<ol> 4) Filming your answers
    <li>    When you are ready you can film the answers to the questionnaire </li>
    <li>    The guide below will help you</li>
</ol>
<br/>
<br/>
<ul style="width:225px;height:25px;padding-top:1px;position:absolute;top:550px;left:60px;list-style-type:none;" id="menu">
    <li style="list-style-type:none;">
        <a href=./downloads/producingavideo.docx>
            Guide to Producing a Video
        </a>
    </li>
</ul>

<ol> 5)Upload your footage to this website
    <li>    You will find a link below which will take you to the upload page </li>
    <li>    Here you will need to input information about your career and about the academic principle you have chosen </li>
    <li>    You will also need to put all your footage into a zipped folder and upload it - see the instructions below</li>
</ol>
<ul style="width:105px;height:25px;padding-top:1px;position:absolute;top:690px;left:60px;list-style-type:none;" id="menu">
    <li style="list-style-type:none;">
        <a href=./downloads/producingavideo.docx>
            zip files 
        </a>
    </li>
</ul>
<br/>
    If you have any difficulty with any part of this website please do not hesitate to contact us using the details on the home page </div> ';

And this section below is the code for my drop down boxes

include "select.class.php"; 

echo "<form id=\"select_Academic\">";
echo "<select style=\"width:200px;\" id=\"category\" name=\"cat\" >";
echo $opt->ShowAllCategory();
echo "</select>";

echo "<select style=\"width:200px;\"id=\"type\">";
echo "<option value=\"%\">";
echo "Section";
echo "</option>";
echo "</select>";

echo "<select style=\"width:200px;\"id=\"principle\">";
echo "<option value=\"%\">";
echo "Principle";
echo "</option>";
echo "</select>";

If I put the above code in without the include "select.class.php"; everything displays correctly but the drop down boxes don't run the functions as they should.

I have looked at this link Include whole content of a file and echo it

any ideas would be much appreciated

Community
  • 1
  • 1
user3387522
  • 127
  • 4
  • 19

1 Answers1

0

Change

<<<<< this is where i want my drop down boxes to be >>>>

to

[LIST1] [LIST2]

Change

echo "<form id=\"select_Academic\">";
echo "<select style=\"width:200px;\" id=\"category\" name=\"cat\" >";
echo $opt->ShowAllCategory();
echo "</select>";

to $list1 = "" . "" . $opt->ShowAllCategory() . "";

Then do a str_replace( "[LIST1]", $list1, $info );

  • I'm sorry but that answer went straight over my head it didn't make sense to me I'm new to PHP – user3387522 Apr 15 '14 at 13:06
  • Basically you need to change the current echo statements so the data is stored within a string. Once you have this data then you can replace a particular piece of text within the $info variable with some new text (your select lists in this case). –  Apr 15 '14 at 13:08
  • sorry that still didnt make much sence could you show me an example or source of what your talking about ? – user3387522 Apr 15 '14 at 13:35