Second question in two days. Same script. In the while loop there is two rows that build two table cells. The first one that's not out commented is working and the result ends up where it suppose to be. The out commented one is not working and i can not see why.
I have checked the name of the column in the mysql table and that's correct. About 10 columns from the table works. But the last 9 don't. The only thing i can see is that the names of the mysql columns are longer. Can the names be too long?
The ajax call is not making an error. And when I make the Table border =1 i can se that there is a cell but nothing in it. When they are both not out commented the second cancels out the first. But on it's own the first give a result.
Any Ideas?
Sorry for bad grammar or if the solutions was to easy.
Any suggestions are welcome.
getdata.inc.php:
//Output results
if(!$facebook)
{
mysql_close();
echo json_encode('There was an error running the query: ' . mysql_error());
}
elseif(!mysql_num_rows($facebook))
{
mysql_close();
echo json_encode('No results returned');
}
else
{
$output_string = '';
$output_string .= '<table border="0">';
while($row = mysql_fetch_assoc($facebook))
{
$output_string .= '<tr>';
$output_string .= '<td>'.$row['sombem_profiler_customers_first_name'].'</td>';
//$output_string .= '<td>'.$row['sombem_profiler_customers_adress_sending_street'].'</td>';
$output_string .= '</tr>';
}
$output_string .= '</table>';
}
mysql_close();
// This echo for jquery
//$output_string = $_POST['personalNumber'];
echo json_encode($output_string);
?>
ajax.js:
function ajaxCall(){
var pnumber = document.getElementById('search-personalNumber').value;
$.ajax({
url: 'db/getdata.inc.php',
type:'POST',
dataType: 'json',
data: { personalNumber: pnumber },
success: function(output_string){
$('#result_table').append(output_string);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
}
It was the special characters that was the problem. I found this script on the internet.
function umlaute($text){
$returnvalue="";
for($i=0;$i<strlen($text);$i++){
$teil=hexdec(rawurlencode(substr($text, $i, 1)));
if($teil<32||$teil>1114111){
$returnvalue.=substr($text, $i, 1);
}else{
$returnvalue.="&#".$teil.";";
}
}
return $returnvalue;
}
and
$output_string .= '<td>'.umlaute($row['comhem_profiler_customers_adress_sending_street']).'</td>';
This converted the charcters to html variants. Thanks for sending me on the right path. Cheers!