Skip to content

Instantly share code, notes, and snippets.

@greggles
Created September 26, 2011 18:47
Show Gist options
  • Save greggles/1243016 to your computer and use it in GitHub Desktop.
Save greggles/1243016 to your computer and use it in GitHub Desktop.
1290624_example1
<?php
function example_module_menu() {
$items['example-search-callback'] = array(
'title' => t('Node search'),
'page callback' => 'example_module_callback',
'access callback' => TRUE,
'type' => MENU_CALLBACK
);
return $items;
}
function example_module_callback() {
$output = '';
$search = $_GET['search_keyword'];
$results = db_query("SELECT nid, title FROM {node} WHERE title like '%%$search%%';")
while ($node = db_fetch_object($results)) {
$output .= '<a href="/node/'. $node->nid .'">'. $node->title .'</a>';
}
return $output;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment