Sunday, August 28, 2011

Add Scrolling Headlines Widget to Your Blog for Professional Blog Design

Scrolling Headlines widget shows recent post titles of your blog like scrolling news headlines as seen in new web sites and TV news channels. Adding the widget to your blogger beta is very easy. In the following form

  1. Enter your blog name
  2. Enter the number of recent post titles which needs to be shown by the widget
  3. Click on Add Widget to my blog
Customize Headlines Scroller Widget

Your blog address:

Number of posts:


Open posts:

Headlines bullet:

Please leave a comment or send a message through Contact Me form (available in the right side top corner) if would like to suggest enhancements to this widget.

In the coming weeks I'm going to release few more widgets. Please do check the site often for updates or subscribe to our news letter. The list of Widgets which will be released soon are

  1. Scrolling Comments Widget
    • Shows comments of your posts as a scrolling headlines text
  2. Scrolling Comments Widget (Comments of a single post)
    • Shows comments of the current post alone as a scrolling headlines text
  3. Recent Posts Widget
    • Show recent posts of the blog
  4. Recent Posts Widget(specific label)
    • Show recent posts of the blog which are labeled with a specific word

You can also suggest us if you have any widget concept in your mind.We will try our level best to develop the widget for you.

Update on 15-July-2007

Printing XML: Why CSS Is Better than XSL

Longtime readers of will remember the battles between XSL and CSS that took place in these columns in 1999 and that were emorialized in XSL and CSS: One Year Later. Since then, the two languages have coexisted in relative peace: CSS is now used to style most web sites, XSLT (the transformation part of XSL) is used by many server-side, and XSL-FO (the formatting part of XSL) has found a niche in the printing industry. A recent entry in the blog of a web luminary may signal the start of a second round of hostilities. Norman Walsh, a member of the W3C’s Technical Architecture Group and co-author of the W3C’s Web Architecture document (WebArch), recently blogged: … web browsers suck at printing. … And CSS is never going to fix it. Did you hear me? CSS is never going to fix it. It’s unclear if this statement is a prediction or a threat. Or just blogging on a bad day. Anyway, the pronounciation of CSS’ printing ineptness gives us a splendid opportunity to explain why CSS is a better language than XSL for most printing needs. As we have just used CSS to style a 400-page book which will be published later this year (Cascading Stylesheets, designing for the web by HÃ¥kon Lie and Bert Bos, 3rd ed, forthcoming from Addison-Wesley, this year), this is not purely an academic excercise in stylesheet linguistics. So, would-be authors should continue reading. The Problem Both camps agree that a printed document is, in many ways, more difficult to format than on-screen presentation. A printed document must be split into numbered pages, with added headers and footers. Page margins must be specified, and they may be different on left and right pages. References that appear as hyperlinks on-screen often include page numbers on paper. The disagreement starts with how best to express all this. Walsh’s solution is to write a 1000-line XSL transformation that generates XSL-FO, which is subsequently turned into PDF. We will argue that it’s much easier for most authors to express styling in CSS; in the case of the WebArch document, one can reuse the existing CSS stylesheets (200 lines or so) and add some print-specific lines. And, although rowsers tend to focus on dynamic screens rather than on printing, products like Prince happily combine CSS with XML and produce beautiful PDF documents. (Some disclosure at this point is appropriate. We, the authors, have been actively involved in shaping CSS and are now working hard to build software–Opera and Prince–that supports CSS.) The Flavors Before going into the print-specific features, let’s compare the basic flavors of XSL and CSS. Consider this fragment from Walsh’s XSL transform: The purpose of this code is to select certain elements (specified in the match attribute) and to set certain formatting properties on these elements (e.g., font-size). Using CSS, this can be written: div.head p.copyright { margin-top: 8pt; margin-bottom: 8pt; font-size: 75% } Compare the two fragments. Which do you find more readable? Which language would be easier to learn? Explaining this XSL snippet to a non-programmer would also be awkward: always The CSS equivalent, however, is more intuitive: ol li:first-of-type { page-break-after: avoid } Printing with CSS As we all know, simple tools cannot always perform advanced tasks.Even if CSS were able to simplify some fragments, it wouldn’t do much good if the language had inherent limitations that made it impossible to describe advanced features. The question becomes, then, whether there are any inherent limitations in CSS that could make it unfit for producing printed documents. The answer is no. CSS2, which became a W3C Recommendation in 1998, introduced The concept of pages in CSS. By using it, one can set page breaks (even Internet Explorer supports this) and page margins. More recently, a W3C Candidate Recommendation (called CSS3 Paged Media Module) added functionality to describe headers, footers, and more.Let’s start with a simple example: @page { size: A4 portrait; } This simple statement tells the formatter that the resulting PDF document should be of size "A4" (which is common outside North America), and that the orientation should be portrait. To change the size of the generated PDF document, one simply changes "A4" into another size. Peeking inside the XSL sheet again, we find two 40-line switch statements to enable similar functionality. One of the statements is reprinted in full below for entertainment purposes: 210mm 11in 8.5in 2378mm 1682mm 1189mm 841mm 594mm 420mm 297mm 210mm 148mm 105mm 74mm 52mm 37mm 1414mm 1000mm 707mm 500mm 353mm 250mm 176mm 125mm 88mm 62mm 44mm 1297mm 917mm 648mm 458mm 324mm 229mm 162mm 114mm 81mm 57mm 40mm 11in As the alert reader will already have inferred, the statement lists the heights of many different paper sizes. As such, it is interesting reading. However, we do not understand why this list belongs in a stylesheet. CSS provides a simple and elegant alternative by naming the different sizes in the specification rather than in each stylesheet. Another example that shows the elegant simplicity of CSS is that of page numbering. Page numbers are commonly printed on the "outside" of a page so that they are easily visible when flipping through a book. So, on a right page the page number should be on the right side, and on a left page it should be on the left side. On the first page, there should be no page number. In CSS, you can express this with: @page :left { @bottom-left { content: counter(page); } } @page :right { @bottom-right { content: counter(page); } } @page :first { @bottom-right { content: normal; } } The statements, while not pure English prose, are easily understandable for anyone who has read this far, and it would be a simple exercise for the reader to move the page number from the bottomof each page to the top. Because of size constraints, we’re not going to show you how page numbers are expressed in XSL. We challenge you to find it and then try explaining it to the first person you meet. Reuse and Cascading One reason why the web took off in the early 90′s was the manner in which HTML is authored. By looking at the source code of other documents, web authors could easily get started in web publishing. In a sense, HTML is the most successful open source movement. CSS also encourages reuse of code and has formalized how it works through the cascading rules. For authors, this means they can take an existing stylesheet and add to it their own rules instead of writing a new one themselves. One case in point is how to express page breaks for printed documents. Typically, you want to avoid page breaks after headings, and this can be expressed by adding a simple rule: h1, h2, h3, h4, h5, h6 { page-break-after: avoid; } Here, the first line lists elements to which the second line applies. As a result, the formatter will avoid page breaks after these elements. XSL has no concept of cascading and cannot easily express the above example. Instead of grouping elements, one has to add a rule to each element’s template. Here is what the template for h1 elements looks like: (XSL has chosen another name for the property, i.e., keep-with-next instead of page-break-after.) Likewise, it is easy in CSS to remove text decorations (e.g. underlining) on all elements: * { text-decoration: none } Table of Contents Many documents start with a table of contents (TOC). On-screen, the TOC is clickable and takes the user to the requested section. Paper, being more static in nature, needs references that can be followed manually. A TOC on paper, therefore, lists the number of the page where the section can be found. Expressing this in CSS results in a slightly more complex rule than the examples you have seen so far. Consider this: ul.toc a:after { content: target-counter(attr(href), page); } In English, the rule would read as follows: inside ul elements of class toc, all a elements should be trailed (:after) by some generated content. The generated content is the page number where the target of the link is found. The link is expressed in the href attribute of the a element. One reason for the added complexity is that CSS, contrary to a common misconception, has been designed to work with generic XML as well as HTML. In HTML, links are expressed in href attributes on a elements. In generic XML, however, links can be anywhere, and their position must be specified. Another common feature of TOCs on paper is a dotted line between section titles and the respective page numbers. This is called a leader in typesetting terminology and can be expressed in CSS as follows: ul.toc a:after { content: leader('.') target-counter(attr(href), page); } Compared with this three-line CSS solution, expressing TOCs in the WebArch XSL stylesheet takes more than 50 lines. In fairness, the XSL code also expresses other properties for TOCs (for example, that page breaks should be avoided). The CSS syntax in the above examples is still at the draft stage. By combining the print-specific CSS stylesheet described above with the WebArch document, a nicely formatted PDF document can be created. Multi-Column Layouts On paper, content is often laid out in multiple columns. Stylesheets must be able to express this. Using CSS, one can easily create multi-column layouts: body { column-count: 2; column-gap: 8mm; } The content of the body element will now be poured into two columns, between which there is an 8mm gap. Multi-column layouts are also available in XSL, but the obligatory verbosity/complexity warnings apply. Conclusions So can CSS do everything better than XSL? Not quite. XSL is a Turing-complete language which, in principle, can be used for all programming tasks and is particularly suited for document transformations. Styling documents is only one of many things XSL can do. CSS, on the other hand, has been developed with only one task in mind: styling documents. On the web, CSS is the style sheet language of choice. However, the usefulness of CSS is not limited to screens. If you want to transfer web content--be it XML or HTML--onto paper, there are good reasons to use CSS. The language is radically simpler than that of XSL, and it is suitable both on-screen and on paper. This means that you probably don't have to write a stylesheet at all but can reuse an existing one. Finally, by using CSS you can preserve the semantics of your content all the way to

Wednesday, July 7, 2010

PHP - Printing a random file from a folder

This is one of the easiest ways to ad management out there. It selects a random file from the directory you chose and displays them randomly.
This code is useful if you have ad codes in different files and want to randomly rotate them.

  1. $rmdlist='';

  2. //$rmd_folder is the variable that choses the directory that the files will be in. Mine is images/rmd-img/

  3. // Make sure you DO NOT forget about the "/" at the end or this will not work.

  4. $rmd_folder = "images/rmd-img/";

  5. mt_srand((double)microtime()*1000);

  6. //use the directory class

  7. $imgs = dir($rmd_folder);

  8. //reads all the files from the directory you chose and ads them to a list.

  9. while ($file = $imgs->read()) {

  10. if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))

  11. $rmdlist .= "$file ";

  12. } closedir($imgs->handle);

  13. //now, put all the images into a array

  14. $rmdlist = explode(" ", $rmdlist);

  15. $no = sizeof($rmdlist)-2;

  16. //now, generate a randon number from 0 - the number of images in the directory you chose.

  17. $random = mt_rand(0, $no);

  18. $image = $rmdlist[$random];

  19. //display's the image.

  20. echo '';

  21. ?>

Show headline ticker in your blog

Display a cool headlines ticker in your blogs and change the way it looks!

With our "Headlines widget" you can put a  customized latest posts ticker directly into your blogs unlike a normal code copy and past process.

Like our earlier headlines scroller widget, we developed a clean interface to take the full advantage of this cool feature:

Customize Post Ticker Widget

Blog address:

Number of posts:

Label Text:

Open posts:


MySql Tutorial 6 - Using mysql in Batch Mode

In the previous sections, you used mysqlinteractively to enter queries and view the results. You can also run mysql in batch mode. To do this, put the commands you want to run in a file, then tell mysql to read its input from the file:

shell> mysql < batch-file

If you are running mysql under Windows and have some special characters in the file that cause problems, you can do this:
C:\> mysql -e "source batch-file"

If you need to specify connection parameters on the command line, the command might look like this:
shell> mysql -h host -u user -p < batch-file

Enter password: ********

When you use mysql this way, you are creating a script file, then executing the script.

If you want the script to continue even if some of the statements in it produce errors, you should use the --force command-line option.

Why use a script? Here are a few reasons:

  • If you run a query repeatedly (say, every day or every week), making it a script allows you to avoid retyping it each time you execute it.

  • You can generate new queries from existing ones that are similar by copying and editing script files.

  • Batch mode can also be useful while you're developing a query, particularly for multiple-line commands or multiple-statement sequences of commands. If you make a mistake, you don't have to retype everything. Just edit your script to correct the error, then tell mysql to execute it again.

  • If you have a query that produces a lot of output, you can run the output through a pager rather than watching it scroll off the top of your screen:
    shell> mysql < batch-file | more

  • You can catch the output in a file for further processing:
    shell> mysql < batch-file > mysql.out

  • You can distribute your script to other people so that they can also run the commands.

  • Some situations do not allow for interactive use, for example, when you run a query from a cron job. In this case, you must use batch mode.

The default output format is different (more concise) when you run mysql in batch mode than when you use it interactively. For example, the output of SELECT DISTINCT species FROM pet looks like this when
mysql is run interactively:
| species |
| bird |
| cat |
| dog |
| hamster |
| snake |

In batch mode, the output looks like this instead:

If you want to get the interactive output format in batch mode, use mysql -t. To echo to the output the commands that are executed, use mysql -vvv.

You can also use scripts from the mysql prompt by using the source command or
\. command:
mysql> source filename;

mysql> \. filename

MySql Tutorial 5 - Getting Information About Databases and Tables

What if you forget the name of a database or table, or what the
structure of a given table is (for example, what its columns are
called)? MySQL addresses this problem through several statements
that provide information about the databases and tables it

You have previously seen SHOW DATABASES, which
lists the databases managed by the server. To find out which
database is currently selected, use the
DATABASE() function:

| menagerie |

If you have not yet selected any database, the result is

To find out what tables the default database contains (for
example, when you are not sure about the name of a table), use
this command:

| Tables_in_menagerie |
| event |
| pet |

The name of the column in the output produced by this statement is
where db_name is the name of the
database. See Section, “SHOW TABLES Syntax”, for more information.

If you want to find out about the structure of a table, the
DESCRIBE command is useful; it displays
information about each of a table's columns:
mysql> DESCRIBE pet;
| Field | Type | Null | Key | Default | Extra |
| name | varchar(20) | YES | | NULL | |
| owner | varchar(20) | YES | | NULL | |
| species | varchar(20) | YES | | NULL | |
| sex | char(1) | YES | | NULL | |
| birth | date | YES | | NULL | |
| death | date | YES | | NULL | |

Field indicates the column name,
Type is the data type for the column,
NULL indicates whether the column can contain
NULL values, Key indicates
whether the column is indexed, and Default

specifies the column's default value. Extra
displays special information about columns; for example, if a
column was created with the AUTO_INCREMENT
option, this is shown here.

MySql Tutorial 4 - Retrieving Information from a Table

Just a database system would be useless without some way to write data to the database files, a database would be similarly useless if there were no way to extract the stored data. Amongst the available SQL statements, one of the most frequently used is the SELECT statement. The purpose of the SELECT statement is to retrieve data from a database table based on specified criteria. In this chapter we will cover the use of the SELECT statement in detail.


Retrieving a Single Column

The most basic of SELECT statements simply retrieves a single column of all the rows of a table. The following SQL statements select a database named extract all the product_description column entries in the product table:

USE MySampleDB;
SELECT product_description FROM product;

Once executed, this command will display a list of every product description contained in the product table:

| prod_desc |
| CD Writer |
| Cordless Mouse |
| SATA Disk Drive |
| Ergonomic Keyboard|
4 rows in set (0.00 sec)

Using SELECT to Retrieve Mutiple Columns

So far we have seen how easy it is to extract a single column from each row of a table. In the real world, it is more likely that information from more than one column will need to be retrieved. Fortunately the SELECT statement makes this task easy too. In fact, all that needs to be done is to specify the columns names after the SELECT statement, each separated by a comma. For example, to retrieve data from three columns in our database table:

SELECT prod_code, prod_name, prod_desc FROM product;

The above command will generate the following output if executed from within the mysql tool:

| prod_code | prod_name | prod_desc |
| 1 | CD-RW Model 4543 | CD Writer |
| 2 | EasyTech Mouse 7632 | Cordless Mouse |
| 3 | WildTech 250Gb 1700 | SATA Disk Drive |
| 4 | Microsoft 10-20 Keyboard | Ergonomic Keyboard|
4 rows in set (0.01 sec)

Whilst this approach works fine if you do not want to display all columns in a table, it can become cumbersome in situations where a table contains many columns and you want to list all columns. An easier way to achieve this than specifying every column is to use the wildcard symbol (*) in place of the column names. For example:

SELECT * FROM product;

Restricting Number of Results

When retrieving data from a table it is possible to limnit the number of results that are returned by the SELECT statement using the LIMIT keyword. This keyword is followed by a number indicating how may rows are to be retrieved:

SELECT * FROM product LIMIT 10;

The above command will retrieve only 10 rows from the database table. Both the start and end rows can be specified for reading further into a table. The following example, therefore, extracts rows 10 through 15 of the table:

SELECT * FROM product LIMIT 10, 15;

Eliminating Duplicate Values from Results

It is not unusual for a column value combination to be duplicated throughout multiple rows. This means that when retrieving data, and particularly when retrieving data for a single column in a table, that duplicated values may appear in the results. For example:

SELECT prod_desc FROM product;
| prod_desc |
| CD Writer |
| SATA Disk Drive |
| Cordless Mouse |
| SATA Disk Drive |
| Ergonmoc Keyboard |
| CD Writer |

As we can see from in the above output, our fictitious on-line store sells more than one type of disk drive and CD writer. Whilst the product codes and names are likely to be unique, the descriptions have duplications. If we wanted to get a list of product descriptions devoid of duplications we would use the DISTINCT keyword:

SELECT DISTINCT prod_desc FROM product;

This would result in the following output:

| prod_desc |
| CD Writer |
| SATA Disk Drive |
| Cordless Mouse |
| Ergonmoc Keyboard |


In the chapter we have looked at the ease with which data can be retrieved from a database using the SELECT statement. With the basics covered, it is time to move on to more advance data retrieval topics.