insert in mysql php code example

Example 1: php insert array into mysql table

$matstring=implode("','",$matrix[1]);
mysql_query('INSERT INTO Australia (Price, Company, Days, Weight) VALUES ('$matstring')');

Example 2: insert php code

<?php
$host = "localhost";
$username = "username";
$pass = "";
$db="furniture";


// Create connection
$conn=mysqli_connect($host,$username,$pass,$db);

if(!$conn){
  die("Data connection error");
}
?>

Example 3: how to insert data in mysql using oop php

--  
 -- Table structure for table `tbl_posts`  
 --  
 CREATE TABLE IF NOT EXISTS `tbl_posts` (  
  `post_id` int(11) NOT NULL AUTO_INCREMENT,  
  `post_title` varchar(150) NOT NULL,  
  `post_desc` text NOT NULL,  
  PRIMARY KEY (`post_id`)  
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;  
 --  
 -- Dumping data for table `tbl_posts`  
 --

Tags:

Php Example