Waqas_aamer Waqas_aamer - 7 months ago 11
SQL Question

retrieving data from database sql query

I have configuaration table in database. I want to get data from it. vName=ADMIN_EMAIL row has a column whose name is vValue. there is an email address stored in it. i want to get that value and store it in $toEmail. Kindly Someone guide me here.

$sqldata=mysqli_query($obj,"SELECT * FROM configuration WHERE vName='ADMIN_EMAIL'");
$rowcount=mysqli_num_rows($sqldata);
// $toEmail = "dev.waqas@designbee.us";
$mailHeaders = "From: " . $_POST["userName"] . "<". $_POST["userEmail"] .">\r\n";
if(mail($toEmail, $_POST["subject"], $_POST["content"], $mailHeaders)) {
echo "<p class='success'>Mail Sent.</p>";
} else {
echo "<p class='Error'>".$toEmail.".</p>";
}

Answer

You need to fetch data after executing query.

$row = $sqldata->fetch_array(MYSQLI_ASSOC);
$toEmail= $row['vName']
Comments