I am getting some strange behavior with a PHP page I am coding:

I have some code that displays a MENU (with the letters of the alphabet):

<FORM NAME="getletter" ACTION="Service_Dates_detail.php?id_Event=<?php echo $id_Event; ?>" METHOD="POST">
      <table width="389" border="0" cellspacing="2" cellpadding="2">
        <tr>
          <td width="49" class="style14">Filter:</td>
          <td width="315"><span class="style14">Select Song</span>
            <input type="hidden" name = "id_Event2" value = "$id_Event"  />
            <input type="hidden" name = "type" value = "Getletter"  />          </td>
        </tr>
        <tr>
   <td height="25">
   			<select name="Letter" onchange="document.forms.getletter.submit();">
 			  <option value="" ></option>
			  <option value="A" >A</option>
			  <option value="B" >B</option>
			  <option value="C" >C</option>
			  <option value="D" >D</option>
			  <option value="E" >E</option>
			  <option value="F" >F</option>
			  <option value="G" >G</option>
			  <option value="H" >H</option>
			  <option value="I" >I</option>
			  <option value="j" >J</option>
			  <option value="K" >K</option>
			  <option value="L" >L</option>
			  <option value="M" >M</option>
			  <option value="N" >N</option>
			  <option value="O" >O</option>
			  <option value="P" >P</option>
			  <option value="Q" >Q</option>
			  <option value="R" >R</option>
			  <option value="S" >S</option>
			  <option value="T" >T</option>
			  <option value="U" >U</option>
			  <option value="V" >V</option>
			  <option value="W" >W</option>
			  <option value="X" >X</option>
			  <option value="Y" >Y</option>
			  <option value="Z" >Z</option>
            </select></td>
          <td><select name="id_Song">
            <? echo $dd; ?>
          </select>
            <input name="Song_Add" type="submit" id="Song_Add" value="ADD" /></td>
        </tr>
      </table></FORM>

I am trying to echo back a to the field the last LETTER they picked. I thought this would work:

<FORM NAME="getletter" ACTION="Service_Dates_detail.php?id_Event=<?php echo $id_Event; ?>" METHOD="POST">
      <table width="389" border="0" cellspacing="2" cellpadding="2">
        <tr>
          <td width="49" class="style14">Filter:</td>
          <td width="315"><span class="style14">Select Song</span>
            <input type="hidden" name = "id_Event2" value = "$id_Event"  />
            <input type="hidden" name = "type" value = "Getletter"  />          </td>
        </tr>
        <tr>
   <td height="25">
   	<select name="Letter" onchange="document.forms.getletter.submit();">
			  <option value="" <?php if($Letter =="") { echo "selected"; } ?>></option>
			  <option value="A" <?php if($Letter =="A") { echo "selected"; } ?>>A</option>
			  <option value="B" <?php if($Letter =="B") { echo "selected"; } ?>>B</option>
			  <option value="C" <?php if($Letter =="C") { echo "selected"; } ?>>C</option>
			  <option value="D" <?php if($Letter =="D") { echo "selected"; } ?>>D</option>
			  <option value="E" <?php if($Letter =="E") { echo "selected"; } ?>>E</option>
			  <option value="F" <?php if($Letter =="F") { echo "selected"; } ?>>F</option>
			  <option value="G" <?php if($Letter =="G") { echo "selected"; } ?>>G</option>
			  <option value="H" <?php if($Letter =="H") { echo "selected"; } ?>>H</option>
			  <option value="I" <?php if($Letter =="I") { echo "selected"; } ?>>I</option>
			  <option value="j" <?php if($Letter =="J") { echo "selected"; } ?>>J</option>
			  <option value="K" <?php if($Letter =="K") { echo "selected"; } ?>>K</option>
			  <option value="L" <?php if($Letter =="L") { echo "selected"; } ?>>L</option>
			  <option value="M" <?php if($Letter =="M") { echo "selected"; } ?>>M</option>
			  <option value="N" <?php if($Letter =="N") { echo "selected"; } ?>>N</option>
			  <option value="O" <?php if($Letter =="O") { echo "selected"; } ?>>O</option>
			  <option value="P" <?php if($Letter =="P") { echo "selected"; } ?>>P</option>
			  <option value="Q" <?php if($Letter =="Q") { echo "selected"; } ?>>Q</option>
			  <option value="R" <?php if($Letter =="R") { echo "selected"; } ?>>R</option>
			  <option value="S" <?php if($Letter =="S") { echo "selected"; } ?>>S</option>
			  <option value="T" <?php if($Letter =="T") { echo "selected"; } ?>>T</option>
			  <option value="U" <?php if($Letter =="U") { echo "selected"; } ?>>U</option>
			  <option value="V" <?php if($Letter =="V") { echo "selected"; } ?>>V</option>
			  <option value="W" <?php if($Letter =="W") { echo "selected"; } ?>>W</option>
			  <option value="X" <?php if($Letter =="X") { echo "selected"; } ?>>X</option>
			  <option value="Y" <?php if($Letter =="Y") { echo "selected"; } ?>>Y</option>
			  <option value="Z" <?php if($Letter =="Z") { echo "selected"; } ?>>Z</option>
            </select></td>
          <td><select name="id_Song">
            <? echo $dd; ?>
          </select>
            <input name="Song_Add" type="submit" id="Song_Add" value="ADD" /></td>
        </tr>
      </table></FORM>

But when I use it, only half my page renders and the other half is ignored.

Is there a better way to handle this? Thanks!

Dwdata,

I can't immediately see why the page should break. The code looks good to me.

Have you got the following statement somewhere up top of the page?

<?php
$Letter = isset($_POST['Letter']) ? $_POST['Letter'] : "";
?>

It certainly won't work without this (or similar) but why only half the page should render is a mystery. I guess php must be giving an error and the output stream is terminated.

Try setting error_reporting(E_ALL); (temporarily) at the top of the php file. It may give a clue as to what's going on.

Airshow

Dwdata,

I can't immediately see why the page should break. The code looks good to me.

Have you got the following statement somewhere up top of the page?

<?php
$Letter = isset($_POST['Letter']) ? $_POST['Letter'] : "";
?>

It certainly won't work without this (or similar) but why only half the page should render is a mystery. I guess php must be giving an error and the output stream is terminated.

Try setting error_reporting(E_ALL); (temporarily) at the top of the php file. It may give a clue as to what's going on.

Airshow

Yeah - it is definitely getting the right Letter. Is there a way to build the list via a LOOPING script?

Dwdata,

Yes you can build by looping through the alphabet.

I considered that but I suggest you get rid of whatever bug is causing the half-rendering problem first, otherwise you are introducing new code that might itself be buggy on top of an existing bug.

Have you tried error_reporting(E_ALL); ?

Airshow

The only error i can see in your posted code is that you don't echo the variable $id_event for the value of it's hidden field, you just put the name there as html, but i don't think that would stop your page from being properly interpreted. Could you put the entire file up on this thread as an attachment?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.