Search
 
SCRIPT & CODE EXAMPLE
 

PHP

select in php mysql

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

$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();
?>
  
  //aamirAlshawa
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

select query in php

// objected oriented method
<?php
	$con=new mysqli("localhost","root","","dbname");
	$sql="select * from tbl";
	$res=$con->query($sql);
	
	$while($fetch=$res->fetch_object(){
      echo $fetch->uid;
      echo $fetch->uname;
      echo $fetch->unumber;
    }
  
?>
Comment

select query in php

$mquery = mysql_query("SELECT * FROM 
users where `userid
` = 1");
$result = mysql_fetch_arrray($mquery);
echo $result['name'];
Comment

PREVIOUS NEXT
Code Example
Php :: php array to string 
Php :: laravel wher in 
Php :: wp get tagline php 
Php :: Installation request for phpoffice/phpspreadsheet 1.4.0 - satisfiable by phpoffice/phpspreadsheet[1.4.0] 
Php :: php convert object to array nested 
Php :: laravel include with variable 
Php :: how to convert array to string in php 
Php :: display all errors in blade laravel 
Php :: acf repeater 
Php :: lumen file upload 
Php :: round up built in function php 
Php :: php date first day of month and last month 
Php :: php use variable as object key 
Php :: how validate the becrypt password in laravel 
Php :: cloudflare ip country 
Php :: validate user password laravel8 
Php :: A non well formed numeric value encountered 
Php :: php string beginnt mit 
Php :: laravel image validate 
Php :: create a modal livewire laravel 
Php :: how add new column in larevel with migration 
Php :: retirrar ultimo caracter php 
Php :: get current time in php 
Php :: convert timestamp to date php 
Php :: validation error laravel 8 with custom massage 
Php :: eloquent pluck multiple columns 
Php :: laravel save photo in both local and database 
Php :: how to get plugin directory path in wordpress 
Php :: twig for loop key 
Php :: ajax post json data handle in php 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =