The first thing for running MySQL Queries with PHP, is to create a database table. You can use the following code for creating the database table :
Code:
CREATE TABLE friends (name VARCHAR(30), fav_color VARCHAR(30), brands VARCHAR(30));
INSERT INTO friends VALUES ( "Anna", "Red", "Adidas" ), ( "Tush", "Blue", "Reebok" ), ( "Kena", "Black", "Lewis" ), ( "Gaba", "Orange", "Koutons" )
the above code will create a table for us to work with, that has friends' names, favorite colors, and brands. The first thing we need to do in our PHP file is connect to the database. We do that using this code :
PHP Code:
?php
// Connects to your Database
mysql_connect("your.host.com", "username", "password") or die(mysql_error());
mysql_select_db("Database_Name") or die(mysql_error());
?>
Bookmarks