I am trying to retrieve data from the db in an input field through PHP. Instead of the placeholder, I want to display this retrieved value in the input field if the data exists. I am able to retrieve the data from the db, but it is adding few extra tabs before the actual input.
<input type="text" name="title" id="title" value="
<?php
$title='title';
$clean = trim(retrieve_project_info($email,$title));
echo $clean;
?>">
So, if the input in the db is ‘coldplay’. the retrieved data looks like ‘[tab][tab][tab]coldplay’ and the url has many %09s in it.
I have removed whitespaces by using the trim method. But, trim does not remove tabs.
Any idea how to remove these tabs?
Yes, removing tabs is easy, but you better find out why they are there instead of removing them.
But your code:
would be better written like this:
Does that help removing your tabs?
The reason I suggest this is because retrieve_project_info could output the tabs.
One more observation: If $clean contains ” will your code fail?
EDIT: @palmi
This is how I do it:
And I call that function everywhere where I output raw code to a formfield.