?php if (!sesam_connect ("phonedb", "demo", "otto")) die ("cannot connect"); $result = sesam_query ("select * from phone"); if (!$result) {$err = sesam_diagnostic(); die ($err["errmsg"]);} echo "TABLE BORDER \n"; / / Add title header with column names above the result: if ($cols = sesam_field_array ($result)) {echo" TR TH COLSPAN=".$cols["count"]. "Result: / TH / TR \n"; echo" TR \n"; for ($col = 0; $col $cols["count"]; ++$col) {$colattr = $cols[$col]; / * Span the table head over SESAM's "Multiple Fields": * / if ($colattr["count"] 1) {echo "TH COLSPAN=".$colattr["count"]." ".$colattr["name"]. "(1. .".$colattr["count"] .") / TH \n"; $col += $colattr["count"] - 1;} else echo "TH". $colattr["name"]. "/ TH \n";} echo" / TR \n";} do {/ / Fetch the result in chunks of 100 rows max. $ok = sesam_fetch_result ($result, 100); for ($row=0; $row $ok["rows"]; ++$row) {echo "TR \n"; for ($col = 0; $col $ok["cols"]; ++$col) {if (isset($ok[$col][$row])) echo" TD ". $ok[$col][$row]." / TD \n";} else {echo "TD -empty - / TD \n";}} echo" / TR \n";}} while ($ok["truncated"]) {/ / while there may be more data echo "/ TABLE \n";} / / free result id sesam_free_result($result);?
?php if (!sesam_connect("phonedb", "demo", "toto")) die("cannot connect"); $result = sesam_query("select * from phone"); if (!$result) {$err = sesam_diagnostic(); die($err["errmsg"]);} echo "TABLE BORDER \n"; / / Ajoute l'entête de titre comme nom de colonne if ($cols = sesam_field_array($result)) {echo" TR TH COLSPAN=".$cols["count"]. "Result: / TH / TR \n"; echo" TR \n"; for ($col = 0; $col $cols["count"]; ++$col) {$colattr = $cols[$col]; / * étend les entêtes de la table au dessus des champs multiples * / if ($colattr["count"] 1) {echo "TH COLSPAN=".$colattr["count"]." ".$colattr["name"]. "(1. .".$colattr["count"] .") / TH \n"; $col += $colattr["count"] - 1;} else echo "TH". $colattr["name"]. "/ TH \n";} echo" / TR \n";} do {/ / Lit les résultats par bloc de 100 $ok = sesam_fetch_result($result,100); for ($row=0; $row $ok["rows"]; ++$row) {echo "TR \n"; for ($col = 0; $col $ok["cols"]; ++$col) {if (isset($ok[$col][$row])) echo" TD ". $ok[$col][$row]." / TD \n"; else echo "TD -empty - / TD \n";} echo" / TR \n";}} while ($ok["truncated"]); / / tant qu'il a y encore des données echo "/ TABLE \n"; / / libère les ressources sesam_free_result($result);?