forked from cgutteridge/PHP-SPARQL-Lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.php
39 lines (35 loc) · 848 Bytes
/
types.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
require_once( "sparqllib.php" );
$data = sparql_get(
"http://rdf.ecs.soton.ac.uk/sparql/",
"
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT * WHERE { ?person a foaf:Person . ?person foaf:name ?name } LIMIT 5
" );
if( !isset($data) )
{
print "<p>Error: ".sparql_errno().": ".sparql_error()."</p>";
}
print "<table class='example_table'>";
print "<tr>";
foreach( $data->fields() as $field )
{
print "<th>$field</th>";
print "<th>$field.type</th>";
print "<th>$field.datatype</th>";
print "<th>$field.language</th>";
}
print "</tr>";
foreach( $data as $row )
{
print "<tr>";
foreach( $data->fields() as $field )
{
print "<td>$row[$field]</td>";
print "<td>".$row["$field.type"]."</td>";
print "<td>".@$row["$field.datatype"]."</td>";
print "<td>".@$row["$field.language"]."</td>";
}
print "</tr>";
}
print "</table>";