Issue with php / HTML

See following code:
		<div class="row">
			<div class="col-sm-3 col-xs-3"><div style="padding-left:5px;"><? if ($size == "" && $emsg != "") { ?><span style="color:red;">*&nbsp;</span><? } ?><u>Select Brand/Model</u></div></div>
			<div class="col-sm-3 col-xs-3"><? if ($filttype == "") { ?><input type="text" name = "ctbrand" disabled="true"><? } else { ?>
				<select name="ctbrand" onChange="get_mods();">
					<option value="">-- Select Brand --</option>
					<option value="BAC" <? if ($ctbrand == "BAC") { ?>selected<? } ?>>BAC</option>
					<option value="EVAPCO" <? if ($ctbrand == "EVAPCO") { ?>selected<? } ?>>EVAPCO</option>
					<option value="SPX/MARLEY" <? if ($ctbrand == "SPX/MARLEY") { ?>selected<? } ?>>SPX/MARLEY</option>
					<option value="Other" <? if ($ctbrand == "Other") { ?>selected<? } ?>>Other</option>
				</select>
			<? } ?>	
			</div>
			<div class="col-sm-1 col-xs-1">&nbsp;</div>
<? echo "filttype = " . $filttype . "<br>"; 
 echo "ctbrand = " . $ctbrand . "<br>"; ?>
			<div class="col-sm-3 col-xs-3"><? if ($filttype == "") { ?><input type="text" name = "ctmodel" disabled="true"><? } else { ?>
				<select name="ctmodel" id="ctmodel" onChange="get_dims();">
		<option value="">-- Select Model --</option>
<? // if $_SESSION['ctmodel'] is not null, fill array and select the prior one
		 if ($ctbrand != "") {
			echo "have session ctbrnd = " . $ctbrand . "<br>";
			echo "ns = " . $ns . "<br>";
			for ($i = 0; $i < $ns; $i++) {	
				$ctmod = mysqli_fetch_array($ress,MYSQLI_ASSOC); 
				if ($ctmod['Brand'] == $_SESSION['ctbrand']) {
					$lmodel = $ctmod['Model']; ?>
					<option value="<?print $lmodel; ?>" <? if ($lmodel == $ctmodel) { ?>selected<? } ?>><?print $lmodel; ?></option>
				<? } ?>	
			<? } ?>	
			<? } ?>
		</select><br><span style="visibility:hidden;"><input type="text" name="bother" size="14" id="bother"></span>
			</div>
		</div>

Open in new window


The first two echos properly display. The 2nd two do not, even thought the value of ctbrand is NOT null.

The attached shows the displayed page; you can see the first two echos.

I'm sure it is something simple, I just cannot see it.

Can someone help?
customize_hvac_partial.JPG
Richard KortsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jan LouwerensSoftware EngineerCommented:
Is it possible that where those echos are in the html makes it invalid html, so it's not showing?

Maybe try writing those echos outside of the select element.
0
Richard KortsAuthor Commented:
To Jan,

The other echos are in the HTML also. On the server, php interprets everything into html. To the browsers it is just text.

I dont think that is the issue.

Richard
0
Leonidas DosasCommented:
Check Richard how you define and assign the $ctbrand variable.
if you are referring to this:
Capture.JPGThe code take the $ctbrand as empty string so that is the reason that you don't have echo
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Richard KortsAuthor Commented:
$ctbrand is echoed on line 15, WITH a value.

The if on line 21 says its null. How does it get null from line 15 to line 21?

Thanks,

Richard
0
Leonidas DosasCommented:
The get_dims()  defines the var again in its scope?
0
Richard KortsAuthor Commented:
get_dims() is executed with the onChange event. The value of the form variable ctbrand is set to "EVAPCO" (see line 7 in the code), that does not change. The form variable ctbrand is NOT THE SAME as the php variable $ctbrand.

It would be best if respondents to this issue are knowledgeable in HTML, Javascript & php

Richard
0
Jan LouwerensSoftware EngineerCommented:
Plain text within a select element will not be displayed on the page.

Have you viewed the source of your result page, and made sure that the echo'd text isn't within the source?
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NerdsOfTechTechnology ScientistCommented:
First, I recommend <?php since <? only works when PHP was configured with the --enable-short-tags option. Thus, the shorthand <? doesn't universally work.

Next, you are using print instead of echo when you are attempting to clearly echo $lmodel, assuming these are the two echo's you are seeking since the other echo's in code line sequence won't run while $ctbrand != "". See line #32-33 of my edited code (line #27 of yours with the error).

Lastly, you are echoing these two lines WITHIN the last <SELECT> tag which makes the HTML invalid:
echo "have session ctbrnd = " . $ctbrand . "<br>";
echo "ns = " . $ns . "<br>";

Open in new window


try:

		<div class="row">
			<div class="col-sm-3 col-xs-3"><div style="padding-left:5px;"><?php if ($size == "" && $emsg != "") { ?><span style="color:red;">*&nbsp;</span><?php } ?><u>Select Brand/Model</u></div></div>
			<div class="col-sm-3 col-xs-3"><?php if ($filttype == "") { ?><input type="text" name = "ctbrand" disabled="true"><?php } else { ?>
				<select name="ctbrand" onChange="get_mods();">
					<option value="">-- Select Brand --</option>
					<option value="BAC" <?php if ($ctbrand == "BAC") { ?>selected<?php } ?>>BAC</option>
					<option value="EVAPCO" <?php if ($ctbrand == "EVAPCO") { ?>selected<?php } ?>>EVAPCO</option>
					<option value="SPX/MARLEY" <?php if ($ctbrand == "SPX/MARLEY") { ?>selected<?php } ?>>SPX/MARLEY</option>
					<option value="Other" <?php if ($ctbrand == "Other") { ?>selected<?php } ?>>Other</option>
				</select>
			<?php } ?>	
			</div>
			<div class="col-sm-1 col-xs-1">&nbsp;</div>
<?php 
 echo "filttype = " . $filttype . "<br>"; 
 echo "ctbrand = " . $ctbrand . "<br>"; 
?>
			<div class="col-sm-3 col-xs-3">
<?php if ($filttype == "") {?>
<input type="text" name = "ctmodel" disabled="true">
<?php } else {?>
		<select name="ctmodel" id="ctmodel" onChange="get_dims();">
		<option value="">-- Select Model --</option>
<?php 
		 // if $_SESSION['ctmodel'] is not null, fill array and select the prior one
		 if ($ctbrand != "") {
			for ($i = 0; $i < $ns; $i++) {	
				$ctmod = mysqli_fetch_array($ress,MYSQLI_ASSOC); 
				if ($ctmod['Brand'] == $_SESSION['ctbrand']) {
					$lmodel = $ctmod['Model']; 
?>
					<option value="<?php echo $lmodel; ?>" 
<?php				if ($lmodel == $ctmodel) { ?>selected<?php } ?>><?php echo $lmodel; ?></option>
<?php
				}	
			}
			echo "</select><br>";
			echo "have session ctbrnd = " . $ctbrand . "<br>";
			echo "ns = " . $ns . "<br>";	
		}else{
			echo "</select><br>";
		}
?>
		<span style="visibility:hidden;"><input type="text" name="bother" size="14" id="bother"></span>
			</div>
		</div>

Open in new window

0
Richard KortsAuthor Commented:
Excellent idea, view source revealed the issue. I had misnamed a variable earlier up in the program.

Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.