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

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 :: unable to open file error in php 
Php :: xampp to test on mobile 
Php :: laravel forcefill 
Php :: laravel event generate 
Php :: php unset reference 
Php :: the_post_thumbnail 
Php :: range in php 
Php :: nova laravel image 
Php :: remove item in an array php 
Php :: How to convert a PHP array to JSON object 
Php :: window.location javascript php 
Php :: keep only n elements of array php 
Php :: laravel make component inline 
Php :: get current month php 
Php :: laravel sortby relationship column 
Php :: update user role wordpress 
Php :: required_if laravel 
Php :: Installing PHP and Configuring Nginx to Use the PHP Processor 
Php :: multiple logical condition in laravel query 
Php :: check if phone number is valid php 
Php :: insertgetid laravel 8 
Php :: php group multidimensional array by value 
Php :: pdo close connection 
Php :: every wordpress page redirect to localhost ? 
Php :: get object tyhpe php 
Php :: implode array keys in php 
Php :: laravel make model all with resources api 
Php :: contains php 
Php :: Filtering Eloquent collection data with filter 
Php :: how to convert unix timestamp to date php 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =