we blab programs

Upload: dhanush-gowda

Post on 04-Mar-2016

221 views

Category:

Documents


0 download

DESCRIPTION

mca vtu 4th sem

TRANSCRIPT

Steps to be followed

1) Always begin with the following commands

# service httpd start

or

# service network start

2) To check whether apache server is running in the background

# service httpd status 3) All the HTML, XML, XSLT,CSS, PHP programs should be saved in

# cd /var/www/html 4) Open the Editor and type the program. 5) To run perl programs ( All perl programs should be saved under .pl extension) # cd /var/www/cgi-bin 6) Change the file permissions to executable mode

# Chmod 0777 filename.pl

7) To see the output go to browser and in the address bar type http://localhost/cgi-bin/6a.pl8) For mysql programs

# service mysqld start

# mysql mysql> show databases;

(use any of the databases available or create a new database ) mysql>create database student

mysql>use student

show tables If tables are not available create a new table by the following query statement

create table tablename + attributes

1. Write a Perl program to insert name and age information entered by the user into a table created using MySQL and to display the current contents of this table.

#! /usr/bin/perl

print "Content-type: text/html\n\n";

print "Result of the insert operation ";

use CGI ':standard';

use DBI;

$dbh=DBI->connect("DBI:mysql:satish","root","ghalige");

$name=param("name");

$age=param("age");

$qh=$dbh->prepare("insert into stud values('$name','$age')");

$qh->execute();

$qh=$dbh->prepare("Select * from stud");

$qh->execute();

print "NameAge";

while ( ($name,$age)=$qh->fetchrow())

{

print "$name$age";

}

print "";

$qh->finish();

$dbh->disconnect();

print"";

Name :

Age :

2. Create a XHTML form with Name, Address Line 1, Address Line 2, and E-mail text fields. On submitting, store the values in MySQL table. Retrieve and display the data based on Name.

getName() .
;

echo multiple values:
;

$link=mysql_connect(localhost,root,);

mysql_select_db(mca);

foreach ($xml->student as $student)

{

echo $student->stud_name .
;

echo $student->stud_usn .
;

echo $student->stud_branch .
;

echo
;

$t=mysql_query(insert into student values($student->stud_name,$student->stud_usn,$student->stud_branch));

}

---------------------------------------------------------------

3c.html

A program to get values from database

Enter Name of the person

Search Result

Search Record

4. Build a rails application to accept book information viz. Accession number, title, authors, edition and publisher From a web page and store the information in a database And to search for a book with the title specified by the User and to display the search results with proper

Headings.

1) rails -d mysql lab12

2) cd lab12

3) mysql -u root4) create database lab12_development;

create database lab12_test; create database lab12_production;5) use lab12_development;6) create table books ( id int not null auto_increment, name varchar(80) not null, description text not null, price decimal(8, 2) not null, primary key(id) );

7) ruby script/generate scaffold Book name:string description:text price:float

8) ruby script/generate controller main

//This program has to be typed in /rails_apps/apps/controllers/main(notepad

file)

9) class MainController < ApplicationController

def welcome

@num_books = Book.count

end

def result

@bookid = params[:sid]

@bookz = Book.find(:all, :conditions => "id = #{@bookid}")

end

end// Store this .rhtml file in /rails_apps/apps/views/filename1.rhtml(notepad

file)

10)

Welcome template for books

Entered book id is

Book IdBook NameDetails Price

/tr>

// Store this .rhtml file in /rails_apps/apps/views/filename2.rhtml (notepad

file)

11)

Welcome template for books

Total number of books =

Enter Searching Element:

12) ruby script/server

13) http://localhost:3000/booksOUTPUT: