Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to connect sql database inside php

<?php
    $dbServername = "localhost";
    $dbUsername = "root";
    $dbPassword = "";
    $dbName = "dbname";
    
    $conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
	
    $sql = "SELECT * FROM dbname;";
    $result = mysqli_query($conn, $sql);
    $resultCheck = mysqli_num_rows($result);

    if ($resultCheck > 0) {
      while ($row = mysqli_fetch_assoc($result)) {
        echo $row['sql_row_name'] . "<br>";
      }
    }
?>
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #connect #sql #database #php
ADD COMMENT
Topic
Name
2+2 =