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 :: merge two objects in php 
Php :: unique validation on update laravel 
Php :: laravel not finding asset files in public directory 
Php :: Add Laravel .env variable to Vue component 
Php :: email validation in laravel 
Php :: Check duplicate email in laravel using jQuery 
Php :: laravel get last 5 records 
Php :: docx file validation laravel 8 
Php :: twig limit text 
Php :: php loop through string 
Php :: php read xml file into array 
Php :: laravel test specific class 
Php :: increase the number in php by a certain percentage 
Php :: how to run laravel project 
Php :: file original extensions laravel 
Php :: ubuntu php7.4-curl : Depends: libcurl3 (= 7.44.0) but it is not going to be installed E: Unable to correct problems, you have held broken packages. 
Php :: where date laravel 
Php :: wordpress convert non negative 
Php :: php append file 
Php :: how to fetch particular css file in wordpress 
Php :: laravel word count utf8 
Php :: php artisan optimize command 
Php :: laravel get extension from url 
Php :: PHP strrchr — Find the last occurrence of a character in a string 
Php :: check if a string is url or not php 
Php :: a backwards counting forloop 
Php :: register acf options page 
Php :: php pass a variabele to js 
Php :: sort multi array php 
Php :: how check if method is not in class in php 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =