Answers for "php mysqli query result"

PHP
3

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'];
}
Posted by: Guest on October-06-2020
0

mysqli_query print result

if (isset($_POST['0'])) {
 $sql = "SELECT email FROM CommercialEmails WHERE articleid = '$_POST[article]' AND dripid = 1 AND sent='a'";
 $resultsd1 = mysqli_query($conn, $sql);

 while ($row = mysqli_fetch_assoc($resultsd1))
 {
    echo $row['email'];
 }
}
Posted by: Guest on May-30-2021

Browse Popular Code Answers by Language