Home > PHP & MySQL > Easy Steps to Store & Retrive Data’s from Database using PHP & MySQL

Easy Steps to Store & Retrive Data’s from Database using PHP & MySQL

Step 1 : Design HTML Form.

Step 2 : Create Database in phpmyadmin.

Step 3 : Create Table in phpmyadmin.

Step 4 : Write this code in php file to insert & retrieve values from database.

  1. variable name=mysql_connect(“serner name”,”user name”,”password”);
  2. mysql_select_db(“database name”,variable name);
  3. $sql=”INSERT INTO tablename(col1,col2,col3) VALUES(‘$_POST[name]’,’$_POST[name]’,’$_POST[name]’)”;
  4. mysql_query($sql,$con); (or)
  5. mysql_query(“INSERT INTO vijay1(name,age,salary) VALUES(‘$_POST[name]’,’$_POST[age]’,’$_POST[salary]’)”);
  6. $result=mysql_query(“SELECT * FROM table name”);
  7. while($row=mysql_fetch_array($result))
    {
    echo $row[‘name’].” “.$row[‘age’].” “.$row[‘salary’];
    }
  8. mysql_close($con);
  1. May 17, 2011 at 12:59 pm

    Needed help to insert and retrieve data from the same page as these one itself….

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: