Archive for the ‘ Php ’ Category

Prototype ajax updater response

Very important: for each php response add this line – with the appropriate charset

header('Content-type: text/html; charset=iso-8859-1');
date("Y-m-d H:i:s");

MySql result to table (with header)

echo '<table>';
$request = "SELECT id, title, name, adr, ulf FROM truc";
$result  = mysql_query($request);
echo '<tr>';
for($i = 0; $i < mysql_num_fields($result); $i++) {
	echo '<td>';
	echo mysql_field_name($result,$i);
	echo '</td>';
}
echo '</tr>';
while($line = mysql_fetch_assoc($result)){
	echo '<tr>';
	foreach ($line as $item) {
		echo '<td>';
		echo $item;
		echo '</td>';
	}
	echo '</tr>';
}
echo '</table>';

Header XML

header("Content-Type: text/xml");
echo '<?xml version="1.0" encoding="utf-8" ?>';