Markup not displaying from PHP script

Associate
Joined
4 Mar 2007
Posts
315
Location
United Kingdom
Ok so I have a table generating input fields with dynamic names based upon the previous selection made on another page. It displays the relational children from the previous parent categories, however I have now bumped into a new problem. It seems that the markup although working is not appearing in the page source. Could anyone lend a suggestion as to why this could be the case:

The PHP is as follows:
Bear in mind that the <form> tags are outside of this script they display.
PHP:
$c = 0;
       foreach($_POST as $k => $v){
           if($v == 'present'){
               $pre = 'percentage_';
               $post = $pre.$k;
               $val[$k] = $_POST[$post]; // store all present percentage elements in an array.
               $posts[$c] = $k; // Make an array of posts.
               $percent[$k] = $_POST[$post]; // Get the percentage of the selected values.
               $c++;
           }
       }

       /*
        * Count the total number of references within the array so that, which is relational to the total number
        * of elements selected on the previous page.
        */

       $max = count($posts);
       for($i=0;$i<$max;$i++){
           $sql = mysql_query("SELECT * FROM default_analysis_list_sub WHERE element = '".$posts[$i]."' ");

           $m = mysql_num_rows($sql); // Count the number of rows for the current itteration element.
           for($j = 0; $j<$m; $j++){
                $child = mysql_result($sql, $j, 'sub_element');
                $parent = mysql_result($sql, $j, 'element');
                if($j == 0){
                    echo "</fieldset><fieldset><legend><b>".$parent.": ".$percent[$parent]."%</b></legend>";
                    echo $child."<input type=\"radio\" name=\"".$child."\" value=\"present\"> Yes <input type=\"radio\" name=\"".$child."\" value=\"absent\" checked> No <input type=\"text\" name=\"percentage_".$child."\" />% of EQF<br />";
                }
                if($j > 0){
                    echo $child."<input type=\"radio\" name=\"".$child."\" value=\"present\"> Yes <input type=\"radio\" name=\"".$child."\" value=\"absent\" checked> No <input type=\"text\" name=\"percentage_".$child."\" />% of EQF<br />";
                }
           }

       }

The output is fine the form is display it's content, but within the markup all you can see is this:

Code:
<form action="default_analysis_c.php?building_name=mike_building&project_name=mike_project&survey_name=Default&quality=3" method="post"> 
<br /> 
<b>Notice</b>:  Unde in <b>/Applications/MAMP/htdocs/combicycle/default_analysis_b.php</b> on line <b>32</b><br /> 
</fieldset><br /><input type="submit" /> 
</form>

Well line the "undefined" on line 32 happens to be a variable I have defined called:

PHP:
$max = count($posts);

any ideas?
 
Also added did a bit more tweaking the error is definitely to do with the loops as i've tried running it like so:

PHP:
       $i = 0;
       do{
           echo "<input type='text' name='".$i."' />";
           $i++;
       }while($i < $max);

Yet it still doesn't seem to appear in the mark up.
 
What's the value of $max?

Code:
$posts[$c] = $k; // Make an array of posts. 
...
$max = count($posts);

it's the number of arrays that have been populated as a result of any $_POST that contained "present".

For example,

The visitor clicks the Y radio button instead of N. As they submit all yes' have a value of "present". The script then cycles through each post (foreach) and assigns them to the $posts array for each one that is "present".

$max then stores the number of values in the array. Ie if there were 3 Y's then there will be 3 references within the $posts array. Thus $max will be 3 as a result of counting the array.
 
Last edited:
Hrm I over looked just escaping a default for the $post value then, I will do that, fingers crossed it's glitching out on that.
+ Thanks Muel for the website, bookmarked!
 
Back
Top Bottom