Databases| SQL| MySQL| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
PHP SQL Script 
 

PHP SQL Script is useful to perform the operation of SQL queries in PHP. The PHP is a server side scripting language and open source software.

 

PHP SQL Script

                         

PHP SQL Script is useful to perform the operation of SQL queries in PHP. The PHP is a server side scripting language and open source software. The PHP supports many databases like MySQL, Oracle, Sysbase, Solid etc. 

Understand with Example

The Tutorial illustrate an example from 'PHP SQL Script'. To make use of sql query in PHP, we create sql_script.php begins with <?php and end with ?>. The <?php enclosed variable con which is assigned to the mysql_connect ( ) function that accept the parameter like "local host", "user" and password to execute the SQL query in PHP. We create a MySQL database which consists of a table "emp_counter" with three column that is id of integer type, name of varchar type , reset_counter of datetime type. We insert a values ('1', 'sandeep', 'SYSDATE()' ) in the table. The Select statement is used to return the records details from table 'emp_counter'. Finally the print is used to print the successful insertion of values into the table 'emp_counter' database.

 

Table: emp_counter

Source Code of sql_script.php 

<?php
  $mysql_db = "test";
  $mysql_user = "root";
  $mysql_pass = "root";
  $con = mysql_connect("localhost", $mysql_user, $mysql_pass);
  mysql_select_db($mysql_db, $con);

  $drop_table = "DROP TABLE if exists emp_counter ";
  mysql_query($drop_table, $con);

  $create_query = "CREATE TABLE emp_counter (id INT NOT NULL AUTO_INCREMENT, 

   name VARCHAR(250), reset_counter DATETIME, PRIMARY KEY(id))";

  mysql_query($create_query, $con);
  print("Table Creation for <b>emp_counter</b> successful!<p>");

  $insert = "INSERT into emp_counter VALUES (1, 'sandeep', SYSDATE())";

  mysql_query($insert, $con);
  print("Inserted new counter successfully for this page");
?> 

Download Source Code

 

Output:

                         

» View all related tutorials
Related Tags: sql mysql c table sed tab if ie record records to ci e use trie pe from m tr spec

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.