Skip to content

Instantly share code, notes, and snippets.

@sleepdeprecation
Created January 2, 2012 02:40
Show Gist options
  • Save sleepdeprecation/1549064 to your computer and use it in GitHub Desktop.
Save sleepdeprecation/1549064 to your computer and use it in GitHub Desktop.
Display all pages from a drupal site
<?php
$q = "
SELECT node.vid,node_revisions.title,node_revisions.body from node_revisions,node WHERE node_revisions.vid = node.vid and node.type = 'page'
";
$c = mysql_connect("[host]", "[user]", "[pass]");
mysql_select_db("[db name]");
$r = mysql_query($q, $c);
$link = array();
while ($row = mysql_fetch_array($r)) {
array_push($link, $row);
}
foreach ($link as $l) {
echo "<li><a href='#" . $l['vid'] . "'>" . $l['title'] . "</a></li>";
}
foreach ($link as $l) {
echo "<div id='" . $l['vid'] . "'><h2>" . $l['title'] . "</h2>" . $l['body'] . "</div>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment