so this is my problems short version:
This works:
$query = mysql_query("SELECT * FROM `some_table`
WHERE IF (LENGTH('$some_variable') > 0, `$other_variable` LIKE
'%$some_variable%' , 0)");
I get a result go through it with a while pack it all in an array and with json_encode send it back to my ajax file, where i list the result. And it works perfectly.
But when i ad one more thing to the query it just gives back empty, so this doesn’t work:
$query = mysql_query("SELECT *
FROM `some_table`
WHERE `something` = `some_other_thing` AND
IF (LENGTH('$some_variable') > 0, `$other_variable`
LIKE '%$some_variable%' , 0)");
So with that AND things just don’t work, but only whit ajax, i mean if i simply print the array out php works superbly.
Thanks in advance.
This is the rest of my php
while ($value = mysql_fetch_array($query)) {
$result[] = array
(
gyarto => $value['gyarto'],
termekcsalad => $value['termekcsalad'],
kiszereles => $value['kiszereles']
);
}
echo json_encode($result);
and my jquery:
$.ajax({
url:"updates/isu.php",
type:"POST",
data: form,
dataType: "json",
success: function(data) {
$.each(data, function(i)
{
$("#result table").append('<tr><td>'+data[i].gyarto+' '+data[i].termekcsalad+' '+data[i].kiszereles+'</td></tr>');
});
}
});
});
Try:
Also here is an exemple on how to use the mysql_fetch_array