connect_error) {     die("Connection failed: " . $conn->connect_error); }  echo "Connected successfully"; ?>"> connect_error) {     die("Connection failed: " . $conn->connect_error); }  echo "Connected successfully"; ?>">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

Conection <?php $servername = "localhost"; $username = "username"; $password = "password"; // Create connection $conn = new mysqli($servername,

Similar presentations


Presentation on theme: "Conection <?php $servername = "localhost"; $username = "username"; $password = "password"; // Create connection $conn = new mysqli($servername,"— Presentation transcript:

1

2 Conection <?php $servername = "localhost"; $username = "username"; $password = "password"; // Create connection $conn = new mysqli($servername, $username, $password); // Check connection if ($conn->connect_error) {     die("Connection failed: " . $conn->connect_error); }  echo "Connected successfully"; ?>

3 Select data $sql = "SELECT id, firstname, lastname FROM MyGuests"; $result = $conn->query($sql); if ($result->num_rows > 0) {     // output data of each row     while($row = $result->fetch_assoc()) {         echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";     } } else {     echo "0 results"; }

4 create table in database
//create table in database $sql1 = " CREATE TABLE IF NOT EXISTS `test` ( `id` int(11) NOT NULL auto_increment, `type` text NOT NULL, `command` text NOT NULL, `value` text NOT NULL, UNIQUE KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1"; $maketable = mysql_query($sql1); if (!$maketable) { die('Could not create table: ' .mysql_error()); }


Download ppt "Conection <?php $servername = "localhost"; $username = "username"; $password = "password"; // Create connection $conn = new mysqli($servername,"

Similar presentations


Ads by Google