Search
 
SCRIPT & CODE EXAMPLE
 

PHP

query sql in php

$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";
}
$conn->close();
Comment

sql in 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>";
      }
    }
?>
Comment

PREVIOUS NEXT
Code Example
Php :: create migration, controller, model and seeder laravel 
Php :: mysqli last index php 
Php :: add log in laravel 
Php :: php check request method 
Php :: wordpress is home page 
Php :: carbon get time 
Php :: hmtl remove tag php 
Php :: updating-product stock quantity programmatically woocommerce 
Php :: wordpress programmatically logout 
Php :: only display part of string php 
Php :: laravel exists eloquent 
Php :: php strftime 
Php :: get taxonomy term meta by id 
Php :: separate numbers with commas laravel 
Php :: get am pm 12 hour timee laravel 
Php :: laravel check empty string 
Php :: laravel get data from this year 
Php :: create a wp plugin 
Php :: replace multiple characters one string php 
Php :: php foreach random 
Php :: laravel 8 validation required if another field is not null 
Php :: add two numbers as string in php 
Php :: 2 decimal round using php 
Php :: php artisan ui tailwind css 
Php :: mysql secure 
Php :: wordpress get post type 
Php :: implode and explode in php 
Php :: laravel date format 
Php :: laravel middleware route 
Php :: the_post_thumbnail 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =