[Solved]words are cuttting off quotation problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
atypk
Forum Newbie
Posts: 4
Joined: Sat Nov 22, 2003 4:06 am

[Solved]words are cuttting off quotation problem

Post 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.
Last edited by atypk on Sat Apr 09, 2005 3:12 am, edited 1 time in total.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Change

Code: Select all

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

Code: Select all

echo "<option value=\"$row2->status_name\" ";
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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.
Post Reply