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

select sql in php

<?php
$mysqli = new mysqli("localhost","my_user","my_password","my_db");

if ($mysqli -> connect_errno) {
  echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
  exit();
}

$sql = "SELECT Lastname, Age FROM Persons ORDER BY Lastname";
$result = $mysqli -> query($sql);

// Associative array
$row = $result -> fetch_assoc();
printf ("%s (%s)
", $row["Lastname"], $row["Age"]);

// Free result set
$result -> free_result();

$mysqli -> close();
?>
//eng.aamirAlshawa
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

query php

<?php 
// MySqli connection
$mysqli = new mysqli("localhost", "my_username", "my_password", "my_database");

// Errors
if($mysqli->connect_error) {
  echo "<b>Failed to connect to MySQL: </b>" . $mysqli->connect_error;
}

// Query
$selectQuery = $mysqli->prepare("SELECT * FROM my_table");
$selectQuery->execute();
$selectQueryResult = $selectQuery->get_result();

// Loop 
while($selectQueryRow = $selectQueryResult->fetch_array()) {
  echo $selectQueryRow['my_column'];
}

// Example
$selectUsername = $mysqli->prepare("SELECT * FROM users");
$selectUsername->execute();
$selectUsernameResult = $selectUsername->get_result();
while($selectUsernameRow = $selectUsernameResult->fetch_array()) {
  echo $selectUsernameRow['username'];
}
Comment

php query

xPawSourceQueryExceptionInvalidPacketException: Failed to read any data from socket in C:xampphtdocsminecraftvendorxpawphp-source-query-classSourceQueryBaseSocket.php:50
Stack trace:
#0 C:xampphtdocsminecraftvendorxpawphp-source-query-classSourceQuerySocket.php(76): xPawSourceQueryBaseSocket->ReadInternal(Object(xPawSourceQueryBuffer), 1400, Array)
#1 C:xampphtdocsminecraftvendorxpawphp-source-query-classSourceQuerySourceQuery.php(212): xPawSourceQuerySocket->Read()
#2 C:xampphtdocsminecraftView.php(27): xPawSourceQuerySourceQuery->GetInfo()
#3 {main}
Comment

PREVIOUS NEXT
Code Example
Php :: how to add dummy records using factory in laravel 8 
Php :: isset blade laravel 
Php :: php salto de linea 
Php :: php array continued 
Php :: php form get 
Php :: jetstream seed user with team 
Php :: laravel before migration 
Php :: php regex string start 
Php :: laravel where in subquery 
Php :: php return json response with status code 
Php :: formdata jquery ajax php 
Php :: php base64 encoded image to png 
Php :: pegar parte da string php 
Php :: php get last index end in foreach 
Php :: get cart item by cart item key woocommerce 
Php :: woocommerce change sale text 
Php :: bind in pdo 
Php :: codeigniter form_validation email 
Php :: Laravel - create model, controller and migration in single artisan command 
Php :: how to override default name for apiresourc route in laravel 
Php :: How to copy all files from one folder to another in PHP? 
Php :: convert string to datetime symfony 
Php :: php append line to file 
Php :: Add 2 hours to current time in cakephp 
Php :: datediff in hour query builder laravel 
Php :: wordpress get child posts 
Php :: newline in php 
Php :: php connect ms sql server 
Php :: how refresh the record of data in laravel 
Php :: php intl 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =