Select previous/next nodes of same content type programmaticaly in Drupal 7 there are modules out there for my problem, but they are not stable and also i need to be able to manipulate the result so here we go:

i need to provide a block on a certain node type which offers a previous and next link to cycle through the nodes of the same content type.

how can i select the previous and next node programmatically using db_query() and then output the links to them?

thanks in advance for your help
Clive is right. 
But $prev_nid is looking for the first node in the table.
So you could add an ORDER BY, like this:

$prev_nid = db_query("SELECT nid FROM {node} WHERE type = 'my_type' AND created &lt; :created ORDER BY created DESC LIMIT 1", array(':created' =&gt; $node-&gt;created))-&gt;fetchField();
$next_nid = db_query("SELECT nid FROM {node} WHERE type = 'my_type' AND created &gt; :created ORDER BY created LIMIT 1", array(':created' =&gt; $node-&gt;created))-&gt;fetchField();