Page 1 of 1

[Solved]words are cuttting off quotation problem

Posted: Tue Mar 29, 2005 2:08 am
by atypk

Code: Select all

echo "<option value=$row2->status_name "; 
			if ( $row->status == $row2->status_name){ 
				echo  " selected " ; 
				echo  "> $row2->status_name </option>" ;
			}
			else
			{
				echo  "> $row2->status_name </option>" ;
			
			}
		}
I want to pass this combo value to javascript variable, I perfectly getting value in javascript but there is one problem if there is any space in data then only first words are shown up rest are cut off please help me out.there is some quotation mark problem, I try many ways but all invain. I think $row->status_name should be in quotation. Please tell me how to do that.

Posted: Tue Mar 29, 2005 3:37 am
by anjanesh
Change

Code: Select all

echo "<option value=$row2->status_name ";
to

Code: Select all

echo "<option value=\"$row2->status_name\" ";

Posted: Tue Mar 29, 2005 4:56 am
by CoderGoblin
There are many "methods" in which you can solve this problem. For a full description see the following manual page.

http://www.php.net/manual/en/language.types.string.php

Personally I prefer to use single quotes

Code: Select all

echo '<option value="'.$row2->status_name.'" ';
I all depends on how you, and your collegues (if any) code. The most important thing is everbody who works on the code should use the "company standard" method.