Connect
	
 //=== Create connection    Name file: dbconfig.php ===		
 $server   = "localhost";
 $user     = "root";
 $password = "123";
 $dname    = "php_practice_db";
 $sqlconnection = mysql_connect($server, $user, $password);
 
 //=== Check connection ===
 mysql_select_db($dname, $sqlconnection) or 
 die ("Unable to connect to the database");





MySQL DB

//=== Create database ===
Database: `php_practice_db`

//=== Create table ===
CREATE TABLE IF NOT EXISTS `members` (
  `id` int(15) NOT NULL AUTO_INCREMENT,
  `firstname` varchar(50) NOT NULL,
  `lastname` varchar(50) NOT NULL,
  `email` varchar(50) NOT NULL,
  `phone` varchar(30) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;



Insert

 //=== Create connection
 include_once("dbconfig.php");
 
 //=== Capturing data from login form ===
 $firstname = $_POST['firstname'];	
 $lastname  = $_POST['lastname'];
 $email     = $_POST['email'];
 $phone     = $_POST['phone'];

 //=== Insert data in database
 $doSQL = mysql_query("INSERT INTO members 
                     (firstname, lastname,email, phone) VALUES
		     ('$firstname','$lastname','$email','$phone')");
 if($doSQL){ echo "Inserted"; } else { echo "Not inserted"; }

View

 //=== Create connection ===
 include_once("dbconfig.php");
 
 //=== Get data from table ===
 $get_members = mysql_query("SELECT * FROM members");
 while($show_members = mysql_fetch_array($get_members)) {
 	
	echo $show_members['firstname'];
	echo $show_members['lastname'];
	echo $show_members['email'];
	echo $show_members['phone'];
	
	}
	
Edit
	
 include_once("dbconfig.php");
 
 //=== Capturing data from login form ===
 $id        = $_POST['id'];	
 $firstname = $_POST['firstname'];	
 $lastname  = $_POST['lastname'];
 $email     = $_POST['email'];
 $phone     = $_POST['phone'];

 //=== Save updated information in database ===
 $doSQL = mysql_query("UPDATE members SET firstname='$firstname',
 lastname='$lastname', email='$email', phone='$phone' WHERE id = '$id'");

	
Delete

 //=== Create connection ===
 include_once("dbconfig.php");
 
 //=== Get member id ===
 $id=$_GET['id'];

 //=== Delete member from database ===
 $delete = mysql_query("DELETE FROM members WHERE id='$id'");
 
 
 
 
	
	

Learn PHP & MySQL

PHP for Beginners: learn everything you need to become a professional PHP developer with practical exercises & projects.

It's possible to start making money in less than 2 month if you are passionate about computer.

Contact PHP expert to quickly diagnose and resolve your problem.

PHP programming support and coaching available 24/7

Database development

We build custom database solutions for any size business tailored to your specific needs.

Each database is centralized, easy to use, and secure. Your users can access information 24/7 and see only the data you want them to. Plus - our robust reports & search features lets them see the data just the way they want it.

Software development

We offer full life-cycle software development services in a wide variety of technologies for an equally wide array of industries. Our proven, global delivery service model gives you the power to scale projects up or down to meet deadlines and market demands.

Portal development

We are positioned to deliver portal solutions of a wide variety of types, scope and complexity. And whatever the underlying scenario, we assure delivery of a dynamic experience your customers, partners and employees are instinctively looking for.

Code for Good Program

Code for Good Program provides Hands-On Programming to not only fresh graduate and continuing students but also to those who graduated way back and are still unemployed because of lacking skills or work experience.

It helps them learn, work on industrial standards and put in practice what they learnt by giving back to the community (volunteering) through Open Source Software Development. We are one in Building Rwanda’s future.

Follow us on Facebook

Follow us on Twitter

Get in touch

T: (+250) 788 802 332 | E: support@code.rw