Code:
std.php

<?php

set_magic_quotes_runtime(0);
// Connecting to database named yp_std using optional 
// username & password (vshare)
$db = mysql_connect('localhost','vshare','vshare');
mysql_select_db('yp_std',$db);

if (isset($_POST['place']) && $_POST['place'] != '') {
    $place = $_POST['place'];
    // trim whitespaces if any
    $place = trim($place);
    // searches the std table for the inputted place. 
   //MySql query defined.
    $query = "SELECT * FROM `std` WHERE 
                 `place`='" . mysql_clean($place) . "'";
} else {
    $query = 'SELECT * FROM std';
}
// Fetches the record which has place matching with the inputted place.
$result = mysql_query($query);

echo "<B>STD Code Finder</B><BR><BR>";
if ($result) {
    while ($record = mysql_fetch_assoc($result)) {
         echo 'STD Code for ' . $record['place'] . " is " . $record['std'];
    }
}

//MySql clean function for cleaning sql query
function mysql_clean($query)
{
    if (!is_numeric($query)) {
        return $query;
    } else {
        return mysql_real_escape_string($query);
    }
}
Before executing the program you have to create a database named 'yp_std' with a table 'std'. The table has the following fields : id (primary key, auto increment, numeric), place (varchar 255) and std (varchar 255).

$db = mysql_connect('localhost','vshare','vshare');

Here the second and third parameters (database username & password - vshare) are optional.