Thursday, September 24, 2009

Excel macros delete empty rows

Below are 6 methods that will delete rows from within a selection. If you know the range you can replace "Selection" with your Range(). It is important to note that the least efficient methods involve those that use loops. This is because they only delete one row at a time!
In some examples we turn off Calculation and Screenupdating. The reason we turn off calculation is in case the range in which we are deleting rows contains lots of formulas, if it does Excel may need to recalculate each time a row is deleted, slowing down the macro. The screenupdating being set to false will also speed up our macro as Excel will not try to repaint the screen each time it changes.
Subs: DeleteBlankRows1, DeleteBlankRows3 and both Worksheet_Change events are slightly different as they first check to see if the ENTIRE row is blank.

Sub DeleteBlankRows1()
'Deletes the entire row within the selection if the ENTIRE row contains no data.
'We use Long in case they have over 32,767 rows selected.
Dim i As Long
'We turn off calculation and screenupdating to speed up the macro.
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
'We work backwards because we are deleting rows.
For i = Selection.Rows.Count To 1 Step -1
If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
Selection.Rows(i).EntireRow.Delete
End If
Next i
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub

Sub DeleteBlankRows2()
'Deletes the entire row within the selection if _
some of the cells WITHIN THE SELECTION contain no data.
On Error Resume Next
Selection.EntireRow.SpecialCells(xlBlanks).EntireRow.Delete
On Error GoTo 0
End Sub

Sub DeleteBlankRows3()
'Deletes the entire row within the selection if the ENTIRE row contains no data.
Dim Rw As Range
If WorksheetFunction.CountA(Selection) = 0 Then
MsgBox "No data found", vbOKOnly, "OzGrid.com"
Exit Sub
End If
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
Selection.SpecialCells(xlCellTypeBlanks).Select
For Each Rw In Selection.Rows
If WorksheetFunction.CountA(Selection.EntireRow) = 0 Then
Selection.EntireRow.Delete
End If
Next Rw
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub

Sub MoveBlankRowsToBottom()
'Assumes the list has a heading
With Selection
.Sort Key1:=.Cells(2, 1), Order1:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End With
End Sub

Sub DeleteRowsBasedOnCriteria()
'Assumes the list has a heading.
With ActiveSheet
If .AutoFilterMode = False Then .Cells(1, 1).AutoFilter
.Range("A1").AutoFilter Field:=1, Criteria1:="Delete"
.Range("A1").CurrentRegion.Offset(1, 0).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
.AutoFilterMode = False
End With
End Sub

Sub DeleteRowsWithSpecifiedData()
'Looks in Column D and requires Column IV to be clean
Columns(4).EntireColumn.Insert
With Range("D1:D" & ActiveSheet.UsedRange.Rows.Count)
.FormulaR1C1 = "=IF(RC[1]="""","""",IF(RC[1]=""Not Needed"",NA()))"
.Value = .Value
On Error Resume Next
.SpecialCells(xlCellTypeConstants, xlErrors).EntireRow.Delete
End With
On Error GoTo 0
Columns(4).EntireColumn.Delete
End Sub

To use any or all of the above code:
Open Excel.
Push Alt+F11 to open the VBE (Visual Basic Editor).
Go to Insert>Module.
Copy the code and paste it in the new module.
Push Alt+Q to return to Excels normal view.
Push Alt+F8 and then select the macro name and click Run. Or select Options and assign a shortcut key.

Removing Blank Rows Automatically
The codes above will work fine for removing blank rows from a list that already has some, but as the saying goes "Prevention is better than cure". The two examples below will remove blank rows as they occur. Either code should be placed within the Worksheet module and will occur each time a cell changes on the worksheet.
In both codes you will notice the Application.EnableEvents=False this is often needed within Event codes like this, else the Event will be triggered again once the code executes which in turn will again trigger the Event and so on.....
You will no doubt also notice the GoTo SelectionCode which occurs if the number of cells within the selection exceeds one. The reason for this is an error would occur if the code reached the Target keyword as Target refers to a single cell.
The second example uses the Sort method rather than the EntireRow.Delete and is the preferred method to use if possible. What happens is, any blank rows are placed at the bottom of the range should the entire row be blank.
The use of the keyword Me is a good habit to get into when working within Worksheet and Workbook modules. This was shown to me by my internet friend from Belgium, Geert Dumortier.

Private Sub Worksheet_Change(ByVal Target As Range)
'Deletes blank rows as they occur.
'Prevent endless loops
Application.EnableEvents = False
'They have more than one cell selected
If Target.Cells.Count > 1 Then GoTo SelectionCode
If WorksheetFunction.CountA(Target.EntireRow) = 0 Then
Target.EntireRow.Delete
End If
Application.EnableEvents = True
'Our code will only enter here if the selection is more than one cell.
Exit Sub

SelectionCode:
If WorksheetFunction.CountA(Selection.EntireRow) = 0 Then
Selection.EntireRow.Delete
End If
Application.EnableEvents = True
End Sub

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'Sorts blank rows to the bottom as they occur
'Prevents endless loops
Application.EnableEvents = False
'They have more than one cell selected
If Target.Cells.Count > 1 Then GoTo SelectionCode
If WorksheetFunction.CountA(Target.EntireRow) <> 0 Then
Me.UsedRange.Sort Key1:=[A2], Order1:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
Application.EnableEvents = True
Exit Sub 'Our code will only enter here if the selection is _
more than one cell.

SelectionCode:
If WorksheetFunction.CountA(Selection.EntireRow) = 0 Then
Me.UsedRange.Sort Key1:=[A2], Order1:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
Application.EnableEvents = True
End Sub

To use either one of the above codes:

Open Excel.
Right click on the Sheet name tab.
Select View Code from the Pop-up menu
Copy the code and paste it over the top of the default Event
Push Alt+Q to return to Excels normal view.
Push Alt+F8 and then select the macro name and click Run. Or select Options and assign a shortcut key.

Export All Tables from MS Access Database ToExcel

Public Sub ExportAlltablesToExcel()
Dim dbCurr As DAO.Database
Dim tdfCurr As DAO.TableDef
Dim strFolder As String

strFolder = "C:\Folder\"

Set dbCurr = CurrentDb
For Each tdfCurr In dbCurr.TableDefs
If (tdfCurr.Attributes And dbSystemObject) = 0 Then
DoCmd.TransferSpreadsheet acExport, , tdfCurr.Name, _
strFolder & tdfCurr.Name & ".xls", True
End If
Next tdfCurr

Set tdfCurr = Nothing
Set dbCurr = Nothing

End Sub

Saturday, September 19, 2009

Free and Open Source Graphics Applicationss

Open Source Photo Management. Gallery is an open source, web-based photo management and album organizer application available for Linux and Windows. It's recently out in a Beta 2 release of Version 3.0. Licensed under the GPL, Gallery makes it easy to blend photo management into a web site or blog. There is a Gallery Remote client available for it that lets you upload new sets of photos on-the-fly, and Gallery is available in over 20 languages.
Blender University. This post collects a whopping 25 tutorials you can use to get started with Blender, one of the most popular free, open source 3D animation and graphics applications, for Windows, the Mac and Linux. You can learn how to create a great looking logo, how to execute special effects, and more. Blender has been used to produce striking full-length animated films and is worth getting to know if you haven't tried it. You can also download a great, free book on Blender here, with step-by-step project instructions.
Fantastic Freeware. Aviary is a truly remarkable suite of free, online graphics applications, and it has won many awards, including a recent Webware 100 award. It isn't open source, but it is freeware, and has become much more than the dedicated image editor that it started out as. You’ll find a vector editor, a color palette editor, a tool for creating visual effects, and more. All of the tools are available for you to use within your browser. Aviary also comes with many tutorials, similar to those found online for Photoshop. You can browse many of them here. Definitely give this suite a try.
On-The-Fly Image Editing. IrfanView is one of my main image editors that I reach for, even though I have Photoshop. It loads in an instant, and has a very rich set of tools, including mutlipage TIF support, support for multiple animated GIFs, and you can choose to use a bunch of useful plug-ins. The application isn't open source. It's freeware, but the developers improve it every year and the plug-in community works like an open source community. It's very fast to launch, does great batch image processing, and you may get things done much faster in it than in more bloated graphics applications.
A Free Book on GIMP? In our post "6 Ways to Get Much More Out of GIMP" we collected a number of excellent resources for the powerful, free, open source GIMP graphics application, available for Windows, the Mac and Linux. You'll find a complete, free online book on GIMP, tips on getting plug-ins and more.
Smarter Flickr Sessions. Are you a Linux user who frequently works with images in Flickr? Flickr can often be very slow, and has very limited uploading tools. Check out Kristin's roundup of top uploading applications for Flickr here.
Flexible Freeware. Paint.net is one of the most beloved freeware offerings for Windows. I know many bloggers and site administrators who swear by it. It shines at image and photo editing, with very flexible pallettes of tools. It supports layers, unlimited undo, special effects, and a growing online community provides tutorials and plug-ins for it.
Need a Desktop Publisher? Scribus is a top, free open source desktop publishing application available for Windows, Mac OS/X and Linux. It's useful for PDF creation, and has most professional publishing features found in proprietary products such as InDesign. Linux.com has a nice step-by-step tutorial up on how to create booklets with Scribus. Lisa Hoover also covered some of the best features in Scribus here.
Draw it for Me. Are you looking for free clip art to incorporate with documents, web pages, and desktop publishing materials? Open Clip Art has an archive of user-contributed art that you can feel comfortable using for free.
For Splashy Web Sites. Along the same lines, if you're looking for good graphical templates for web pages, two good places to start are Open Source Web Designs and Open Designs. These sites house thousands of graphical templates, most of them XHTML/CSS-based, that you can use for free.
Photos Meet Gmail. GPhotoSpace is a Firefox extension that enhances your Gmail account with photo album creation, uploading, and sharing features, as we covered here. It's available for Windows and the Mac. Within Gmail, GPhotoSpace gives you links to choose from for creating albums, sending albums to others, deleting albums, maintaining an album inbox and more. All the images are stored by Google as part of your Gmail account, and I recommend setting up a dedicated Gmail account to use with it. This is a very convenient way to work with photos and e-mail for sharing purposes.
On a Thumbnail Basis. Easy Thumbnails is a freeware application that is used widely to create thumbnail images (the small graphics you see when you, say, do a Google Image search and get a page of various graphics back). However, it is also good for scaling images incrementally up or down in size and you can resize large groups of images in batches with it. For example, you can scale all photos you have in one folder up in size at once. Give it a go, and you're likely to find several uses for it.

Thursday, September 17, 2009

Delete duplicate rows from a list in Excel

A duplicate row (also called a record) in a list is one where all values in the row are an exact match of all the values in another row. To delete duplicate rows, you filter a list for unique rows, delete the original list, and then replace it with the filtered list. The original list must have column headers.
 Caution    Because you are permanently deleting data, it's a good idea to copy the original list to another worksheet or workbook before using the following procedure.
  1. Select all the rows, including the column headers, in the list you want to filter.
    Click the top left cell of the range, and then drag to the bottom right cell.
  2. On the Data menu, point to Filter, and then click Advanced Filter.
  3. In the Advanced Filter dialog box, click Filter the list, in place.
  4. Select the Unique records only check box, and then click OK.The filtered list is displayed and the duplicate rows are hidden.
  5. On the Edit menu, click Office Clipboard.The Clipboard task pane is displayed.
  6. Make sure the filtered list is still selected, and then click Copy. The filtered list is highlighted with bounding outlines and the selection appears as an item at the top of the Clipboard.
  7. On the Data menu, point to Filter, and then click Show All.The original list is re-displayed.
  8. Press the DELETE key.The original list is deleted.
  9. In the Clipboard, click on the filtered list item.The filtered list appears in the same location as the original list.
Or simply: Data>Filter>Advanced Filter.

Unique records only and copy to another location.

Creating a Code Search Engine with PHP and MySQL

I'm just a few days away from launching a comprehensive support website for my book, "Beginning PHP and MySQL 5, Second Edition", and among other features, have built a search engine for sifting through the more than 500 code snippets found throughout the book. This was an interesting exercise because it involves a number of storing a fairly significant amount of text within a MySQL database, using MySQL's full-text search facility, and devising an effective way to extract and display the code in the browser.
In this article I'll offer a simplified version of this search engine, introducing you to some compelling PHP and MySQL features along the way. You might adopt what you learn towards building your own search engine, or towards other applications.

The Database Schema

Just a single table is required for the engine's operation. The table, code, serves as the code repository. Each example is stored along with a suitable title and the chapter number in which it appears. Because the search engine should retrieve examples based on keywords found in the example title or in the code itself, a FULLTEXT index has been added for these columns. Because the table contents will rarely change beyond the occasional bug fix, its backed by the read-optimized MyISAM storage engine. The table follows:
CREATE TABLE code (
 id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
 title VARCHAR(50) NOT NULL,
 chapter TINYINT UNSIGNED NOT NULL,
 code TEXT NOT NULL,
 FULLTEXT (title,code)
) TYPE = MYISAM;

Loading the Table

The downloadable zip file containing all of the book's code should be easily navigable so readers can easily retrieve the desired example. To meet this requirement, the zip file contains a number of directories labeled according to chapter number (1, 2, 3, ... 37), and each script is aptly named with a lowercase title and series of underscores, for example retrieving_array_keys.php. Therefore a script capable of dealing with these two organizational matters is required in order to automate the process of loading the scripts into the database.
You might recognize this task as one well suited for recursion, and indeed it is. The following script does the job nicely:
<?php

mysql_connect("localhost","gilmore","secret");

mysql_select_db("beginningphpandmysqlcom");

// Running on Windows or Linux/Unix?
$delimiter = strstr(PHP_OS, "WIN") ? "\" : "/";

function parseCodeTree($path) {

  global $delimiter;

  if ($dir = opendir($path)) {
 
    while ($item = readdir($dir)) {

      // If $item is a directory, recurse
      if (is_dir($path.$delimiter.$item) && $item != "." && $item != "..") {
   
        //printf("Directory: %s <br />", $item);
        parseCodeTree($path.$delimiter.$item);

      // $item is a file, so insert it into database
      } elseif ($item != "." && $item != "..") {

        // Retrieve the chapter number
        $directory = substr(strrchr($path, "$delimiter"), 1);

        //printf("File: %s <br />", $item);

        // Convert the file name to a readable title
        $scriptTitle = str_replace(".php", "", $item);
        $scriptTitle = str_replace("_", " ", $scriptTitle);
  
        // Retrieve the file contents
        $scriptContents = file_get_contents($path.$delimiter.$item);

        // Insert the file information into database
        $query = "INSERT INTO code VALUES('NULL', '$scriptTitle', '$directory', '$scriptContents')";
        $result = mysql_query($query);

      }
    }
    closedir($dir);
  }
  return 1;
}

parseCodeTree('code');

?>
I've purposefully left two printf() statements in the script so you can view the script's logic. Some sample output follows:
Directory: 4
File: array_key.php
File: is_array.php
Directory: 5
File: multidimensional_array.php
File: retrieving_array_keys.php
File: retrieving_array_values.php
File: slicing_an_array.php

Building the Search Engine

With the code and corresponding metadata inserted into the database, all that's left to do is build the search engine. Believe it or not, this is perhaps the easiest part of the project, thanks to MySQL's fulltext search capabilities. Although I've used the symfony framework to abstract the database interaction, for the purposes of this article I've used POPM (Plain Old PHP and MySQL) to build the search engine. The search form is exceedingly simple, and looks like this:
<form method="POST" action="search.php">
Search the code repository:<br />
<input type="text" id="keyword" name="keyword" /><br />
<input type="submit" value="Search!" />
</form>
The search script (search.php) looks something like this. Provided you've used PHP to interact with MySQL before, there shouldn't be any surprises, except for perhaps the query itself. This query takes advantage of MySQL's fulltext feature to compare the keyword against those columns that have been identified as searchable using MySQL's fulltext conditions. These conditions can produce unexpected results without doing some advance reading, so be sure to peruse the appropriate section of the MySQL documentation before building your own queries.
<?php

  mysql_connect("localhost","gilmore","secret");
  mysql_select_db("beginningphpandmysqlcom");

  $keyword = mysql_real_escape_string($_POST['keyword']);

  // Perform the fulltext search
  $query = "SELECT id, title, chapter, code 
            FROM code WHERE MATCH(title, code) AGAINST ('$keyword')";

  $result = mysql_query($query);

  // If results were found, output them
  if (mysql_num_rows($result) > 0) {

    printf("Results: <br />");

    while ($row = mysql_fetch_array($result)) {

      printf("Chapter %s: <a href='displaycode.php?id=%s'>%s</a>", 
       $row['chapter'], $row['id'], ucfirst($row['title']));

    }

  } else {
    printf("No results found");
  }

?>

Simple Connection to MySQL with PHP

The MySQL database is one of the most popular among PHP developers. It's my database of choice, and has held up remarkably well in multiple e-commerce situations. Therefore, you would be correct in assuming that there are numerous well-documented PHP functions you can use in conjunction with your MySQL databases. However, you only need a few of these functions in order to make a simple connection and select some data:


mysql_connect - opens a connection to the MySQL server; requires a hostname, username and password.



mysql_db_select - selects a database on the MySQL server.


mysql_query - issues the SQL statement.




mysql_fetch_array - puts a SQL statement result row in an array.


mysql_free_result - frees the resources in use by the current connection.


mysql_close - closes the current connection.


For the rest of PHP's MySQL-related functions, get thee to the PHP Manual!


Just for argument's sake, let's pretend that MySQL is already installed on your system, and you have a valid username and password for an existing database. Let's also assume that you've created a table on that database, called COFFEE_INVENTORY. The COFFEE_INVENTORY table has three columns: COFFEE_NAME, ROAST_TYPE and QUANTITY.


The rows in the COFFEE_INVENTORY table could be populated with data such as:


French Roast,dark,18


Kenya,medium,6


Ethiopian Harrar,medium,35


Sumatra,dark,8


Columbian,light,12


Now, let's do some PHP. Before you begin, you must know the name of the server on which the database resides, and have a valid username and password for that server. Then, start your PHP code by creating a connection variable:

";
echo "Coffee Name</TH>Roast Type</TH>Quantity</TH>";


After defining the variables within the while loop, print them in table format:

echo "$coffee_name</TD>$roast_type</TD>$quantity</TD></TR>";


The new while loop now looks like this:

while ($row = mysql_fetch_array($sql_result)) {
$coffee_name = $row["COFFEE_NAME"];
$roast_type = $row["ROAST_TYPE"];
$quantity = $row["QUANTITY"];
echo "$coffee_name</TD>$roast_type</TD>$quantity</TD></TR>";
}


After the while loop, close the HTML table:

echo "</TABLE>";


Finally, you'll want to free up the resources used to perform the query, and close the database connection. Failing to do so could cause memory leaks and other nasty resource-hogging things to occur.

mysql_free_result($sql_result);
mysql_close($connection);
?>


The full script to perform a simple connection and data selection from a MySQL database could look something like this:

";
echo "Coffee Name</TH>Roast Type</TH>Quantity</TH>";

// format results by row
while ($row = mysql_fetch_array($sql_result)) {
$coffee_name = $row["COFFEE_NAME"];
$roast_type = $row["ROAST_TYPE"];
$quantity = $row["QUANTITY"];
echo "$coffee_name</TD>$roast_type</TD>$quantity</TD></TR>";
}

echo "</TABLE>";

// free resources and close connection
mysql_free_result($sql_result);
mysql_close($connection);
?>


Please see the PHP Manual for additional MySQL functions, and try using your own tables and SQL statements instead of the examples above.

PHP: A simple MySQL search

Introduction

One of the most important advantages of creating a database driven sites is the ability to perform search queries on the database. Could you imagine searching WeberDev.com if it was written using plain HTML? Not that it couldn't be done, just we would have to rebuild an index of all the pages every time someone adds an example, article and so on.

Now, performing searches on a database driven site is a totally different story (and thankfully much easier).

Grocery list

In order to understand and work a bit with searches we will need a small MySQL driven site. I will use the structure we built at my "Beginners guide to PHP/MySQL - Creating a simple guest book" article. Actually, we will write a search page for the guest book described in the above tutorial, so go on and take a brief look at the PHP code for the guest book, I'm waiting.

Notice that we have a file named links.x, which holds the links to the guest book pages. We will modify it slightly to include a link to the search page (the third <li> statement).

Links.x:
<p></p>
<ul>
<li><a href="index.php3">Display entries</a>
<li><a href="add.php3">Add new entry</a>
<li><a href="search.php3">Search the guest book</a>
</ul>

Ok, done with that.

Searching the database

To tell the truth, we don�t actually search the database, but rather select records from it that correspond to a string we choose. Lets assume we want to search all the records where the users' name matches the search string:

Search.php3:
<html>
<head><title>Searching the Guest Book</title>
</head>
<body bgcolor=#ffffff>
<h1>Searching the Database</h1>
<form method="post" action="srch.php3">
<table width=90% align=center>
<tr><td>search for:</td><td><input type=text name='search' size=60 maxlength=255></td></tr>
<td></td><td><input type=submit></td></tr>
</table>
</form>
<?php include ('links.x');?>
</body>
</html>

This html is rather simple. Just a small form that sends a search string variable to srch.php3.

Srch.php3:
<?
if ($search) // perform search only if a string was entered.
{
mysql_connect() or die ("Problem connecting to Database");

$query = "select * from visitors WHERE Name='$search'";

$result = mysql_db_query("guest_book", $query);

if (
$result)
{
echo
"Here are the results:<br><br>";
echo
"<table width=90% align=center border=1><tr>
<td align=center bgcolor=#00FFFF>Visit time and date</td>
<td align=center bgcolor=#00FFFF>User Name</td>
<td align=center bgcolor=#00FFFF>Last Name</td>
<td align=center bgcolor=#00FFFF>Email</td>
</tr>"
;

while (
$r = mysql_fetch_array($result)) { // Begin while
$ts = $r["TimeStamp"];
$name = $r["Name"];
$last = $r["Last"];
$email = $r["email"];
$comment = $r["comment"];
echo
"<tr>
<td>$ts</td>
<td>$name</td>
<td>$last</td>
<td>$email</td></tr>
<tr> <td colspan=4 bgcolor=\"#ffffa0\">$comment</td>
</tr>"
;
}
// end while
echo "</table>";
} else { echo
"problems...."; }
} else {
echo
"Search string is empty. <br> Go back and type a string to search";
}
include (
'links.x');
?>

Some explanations. This scripts performs the following tasks:

  1. Checks whether a string was entered.
  2. Retrieves all the records that match the search string.
  3. Prints all the retrieved records in a formatted table.

Clearing all the mumbo jumbo, the actual code that we need to work on is:
$query = "select * from visitors WHERE Name='$search'";

Yes, this line does all the work. We will play with it a bit later.

Ok, this query gets all the records where the Name field is equal to the string search. Please note that an exact match is needed.

Lets assume we want to search for a partial string match (i.e. where the search string appears in the filed but as part of the string and not an exact match). We will have to modify the script as follows:
$srch="%".$search."%";
$query = "select * from visitors WHERE Name LIKE' $srch'";

The LIKE comparison argument will return '1' if the Name field has a partial value of $search. Note that I modified $search and added "%" on both ends. This allows to search for the search to ignore the leading characters and the characters following the search string.

Ok, now lets assume we want to search all the field of the table and not only the Name field. In order to do that we need to choose the records with Name LIKE $srch or Last LIKE $srch etc. The translation to MySQL query is:
$query = "select * from visitors WHERE Name LIKE '$srch' || Last LIKE '$srch' || email LIKE '$srch' || comment LIKE '$srch'";

The complete srch.php3 script top to bottom should look like:
<?
if ($search) // perform search only if a string was entered.
{
mysql_connect() or die ("Problem connecting to DataBase");
$srch="%".$search."%";
$query = "select * from visitors WHERE Name LIKE '$srch' || Last LIKE '$srch' || email LIKE '$srch' || comment LIKE '$srch'";

$result = mysql_db_query("guest_book", $query);

if (
$result)
{
echo
"Here are the results:<br><br>";
echo
"<table width=90% align=center border=1><tr>
<td align=center bgcolor=#00FFFF>Visit time and date</td>
<td align=center bgcolor=#00FFFF>User Name</td>
<td align=center bgcolor=#00FFFF>Last Name</td>
<td align=center bgcolor=#00FFFF>Email</td>
</tr>"
;

while (
$r = mysql_fetch_array($result)) { // Begin while
$ts = $r["TimeStamp"];
$name = $r["Name"];
$last = $r["Last"];
$email = $r["email"];
$comment = $r["comment"];
echo
"<tr>
<td>$ts</td>
<td>$name</td>
<td>$last</td>
<td>$email</td></tr>
<tr> <td colspan=4 bgcolor=\"#ffffa0\">$comment</td>
</tr>"
;
}
// end while
echo "</table>";
} else { echo
"problems...."; }
} else {
echo
"Search string is empty. <br> Go back and type a string to search";
}
include (
'links.x');
?>

Wednesday, September 16, 2009

Gnome hotkeys

GNOME is a desktop environment and an international project that includes creating software development frameworks, selecting application software for the desktop, and working on the programs which manage application launching, file handling, and window and task management. GNOME is part of the GNU Project and can be used with various Unix-like operating systems - most notably those built on top of the Linux kernel and the GNU userland.

General Shortcut Keys
Alt + F1 Opens the Applicantions Menu .
Alt + F2 Displays the Run Application dialog.
Print Screen Takes a screenshot.
Alt + Print Screen Takes a screenshot of the window that has focus.
Ctrl + Alt + right arrow Switches to the workspace to the right of the current workspace.
Ctrl + Alt + left arrow Switches to the workspace to the left of the current workspace.
Ctrl + Alt + up arrow Switches to the workspace above the current workspace.
Ctrl + Alt + down arrow Switches to the workspace below the current workspace.
Ctrl + Alt + d Minimizes all windows, and gives focus to the desktop.
F1 Starts the online help browser, and displays appropriate online Help.

Window Shortcut Keys
Alt + Tab Switches between windows. When you use these shortcut keys, a list of windows that you can select is displayed. Release the keys to select a window.
Alt + Esc Switches between windows in reverse order. Release the keys to select a window.
F10 Opens the first menu on the left side of the menubar.
Alt + spacebar Opens the Window Menu .
Arrow keys Moves the focus between items in a menu.
Return Chooses a menu item.
Esc Closes an open menu.
Ctrl + Alt + right arrow Switches to the workspace to the right of the current workspace.
Ctrl + Alt + left arrow Switches to the workspace to the left of the current workspace.
Ctrl + Alt + up arrow Switches to the workspace above the current workspace.
Ctrl + Alt + down arrow Switches to the workspace below the current workspace.
Ctrl + Alt + d Minimizes all windows, and gives focus to the desktop.

Panel Shortcut Keys
Ctrl + Alt + Tab Switches the focus between the panels and the desktop. When you use these shortcut keys, a list of items that you can select is displayed. Release the keys to select an item.
Ctrl + Alt + Esc Switches the focus between the panels and the desktop. Release the keys to select an item.
Ctrl + F10 Opens the popup menu for the selected panel.
Tab Switches the focus between objects on a panel.
Return Chooses the selected panel object or menu item.
Shift + F10 Opens the popup menu for the selected panel object.
Arrow keys Moves the focus between items in a menu. Moves the focus between interface items in an applet also.
Esc Closes an open menu.
F10 Opens the Applications menu from the Menu Bar , if the Menu Bar is in a panel.

Application Shortcut Keys
Ctrl + N New
Ctrl + X Cut
Ctrl + C Copy
Ctrl + V Paste
Ctrl + Z Undo
Ctrl + S Save
Ctrl + Q Quit