In my db I a have table called users. In that table I have a field called usr_loc_id. The content of that field is a city name with its zip code. An example would be : Paris (75018)
In a php script I am at some point echoing out that field value into a custom attribute of a tr tag :
echo '<tr attrLoc='.$row['usr_loc_id'].' class='someClass'>...
My problem is as follows. When i check my debugger, I see that only the city name is take into consideration. The city code with the parenthises is left out. Here below how it looks in the debugger.
<tr attrLoc="Paris" (75018) class="someClass">...
Hope someone can help understand and solve this. Thank you in advance for your replies. Cheers. Marc.
You are missing quotes in the generated html. The literal text of your output is:
Note that lack of quotes. That means the browser’s parser is seeing 3 attributes in this tag:
With proper quoting in your PHP, you can fix this:
or