select option in php using database

I will show you how to add data into select option by fetching data from database. its quite simple. select option is mostly used for registrations & other major activities & forms. select option is useful.

create database named premal. add 1 table named location_country with 2 fields. 1 is for id autoincrement & name.

premal katigar

After that some data into database.

Now get following Code.

<?php
$con=mysql_connect("localhost","root");
mysql_select_db("premal",$con);
?>
<select name="location" id="location">
$query="select name from location_country";
 $result=mysql_query($query);
 if($result)
 {
 ?>
 <option value="NULL">SELECT</option>
 <?php
 while($row=mysql_fetch_array($result))
 {
 ?>
 <option value="<?php $row[0] ?>"><?php echo $row[0] ?></option>
 <?php
 }
 }
 ?> 


</select>

Taking a screenshot of current Activity in Android

In this post I’ll show how you can take a screenshot of your current Activity and save the resulting image on /sdcard.

The idea behind taking a screenshot actually is pretty simple: what we need to do is to get a reference of the root view and  generate a bitmap copy of this view.

screenshot

 

First of all we should retrieve the topmost view in the current view hierarchy, then enable the drawing cache, and after that call getDrawingCache().

Calling getDrawingCache(); will return the bitmap representing the view or null if cache is disabled, that’s why setDrawingCacheEnabled(true); should be set to true prior invoking  getDrawingCache().

 

public Bitmap takeScreenshot() {
   View rootView = findViewById(android.R.id.content).getRootView();
   rootView.setDrawingCacheEnabled(true);
   return rootView.getDrawingCache();
}
And the method that saves the bitmap image to external storage:
public void saveBitmap(Bitmap bitmap) {
    File imagePath = new File(Environment.getExternalStorageDirectory() + "/screenshot.png");
    FileOutputStream fos;
    try {
        fos = new FileOutputStream(imagePath);
        bitmap.compress(CompressFormat.JPEG, 100, fos);
        fos.flush();
        fos.close();
    } catch (FileNotFoundException e) {
        Log.e("GREC", e.getMessage(), e);
    } catch (IOException e) {
        Log.e("GREC", e.getMessage(), e);
    }
}
we have to take permission
Since the image is saved on external storage, the WRITE_EXTERNAL_STORAGE permission should be added AndroidManifest to file:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Using Custom Fonts in Android

By default Android comes with three standard fonts: Droid Sans (default font), Droid Serif, and Droid Sans Mono. They all can be applied to any view that supports styling, such as TextView, Button, by specifying the “android:typeface” attribute in the XML declaration with any of these values: sans, serif, monospace.

<TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="Sans"
   android:typeface="sans" />
<TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="Serif"
   android:typeface="serif" />
<TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="Monospace"
   android:typeface="monospace" />
android-standard-fonts
Using custom fonts in Android is pretty straightforward. First find a free font and put it in the assets/fonts directory. (It’s not mandatory to have a /fonts directory, but if I have a lot of stuff in the /assets directory I organize them in separate directories). Then get a reference to your TextView and create a Typeface object specifying the font path. Lastly, apply the typeface to the TextView.
Now Run this application..