Primary Links:

My Photos

ikhnaton2 @ flickr

Search

Recent comments

Support

Google Egypt Campaign EGYPT Bloggers Blog Flux DirectoryCall for Peace & Openness يوتوبيا مصرية Egyptian Bloggers Group مرصد المدونين

Syndicate

Syndicate content

PHP

Create a Recent Posts Block in Drupal

I needed to make a block in drupal that contain my recent posts and so, I write this code snippet.

<?php

// Get all node IDs and it title from the "node" table
// Customize the types retrieved from the "type" field
// (Status=0 & Moderate=0) mean the post is published
$result mysql_query("SELECT nid, title 
                       FROM node
                       WHERE (type='story' or type='blog' 
                              OR type='flexinode-1')
                       AND NOT (status=0 and moderate=0)
                       ORDER BY nid DESC"

                       or die(
mysql_error()); 

echo "<ul>";
// keeps getting the next row until there are no more to get
while($row mysql_fetch_array$result )) {
   
// Print node titles linked to its page into unsorted list
   
echo "<li>";
   echo 
"<a href=\"http://ikhnaton2.com/
            node/{$row['nid']}\">$row['title']}</a>"
;
   echo 
"</li>"

echo 
"</ul>";

?>

Enjoy :)

Another trick: Display a list of node titles from a specific category

Posted in | | | | Submitted by ikhnaton2 on Fri, 07/10/2005 - 2:26am.
4 comments | 2580 reads

Convert Date/Time to Unix Timestamp using PHP

Very helpful function to convert date/time string to Unix timestamp. I needed this function to update the timestamp field of some comments in my Drupal after migrating them from my blog on blogspot.

Posted in | | | Submitted by ikhnaton2 on Fri, 07/10/2005 - 1:41am.
read more | 2 comments | 2065 reads

Retreiving Information from MySQL using PHP

If you need to get data in your MySQL database and display them on your dynamic PHP page.

In this example we will select everything in our table "example" and put it into a nicely formatted HTML table.
Posted in | | Submitted by ikhnaton2 on Tue, 04/10/2005 - 6:40pm.
read more | add new comment | 1179 reads
Syndicate content