Hi!
I am using JQuery and CakePHP for my application. I have a table Attributes(id,form_id,label,type)
In this table, I have an entry like
1 1 First name Text
2 1 Lastname Text
I have written a CakePhp query to retrieve the id
given the form_id
and the label
$attri = $this->Attribute->find('all', array(
'fields'=> array('Attribute.id'),
'conditions' => array(
'Attribute.form_id' => $id,
'Attribute.label' => $key
)
));
where $key
is my label
and $id
is my form_id
.
However, since the First name includes the space in between, the conditions didn't work well, but it works for Lastname since it didn't have space in between.
How can I fix this?
Edit:
I am using MySQL database. The user can keep whatever the fieldname. I got the parameters $key from a form using $_POST, e.g.:
foreach ($_POST as $key => $value):
echo $key; //displays First name correctly.
But when I use $key in the conditions, only if no spaces are in between the label it accepts, it will return the attribute id, else nothing is returned.
I even tried with using "$key", but it doesn't work either.