Okay so I'm just learning mysqli and I'm having a little trouble putting this code together. I've posted the mysqli query below and then below that is the code I'm trying to combine with the mysqli query and I can't seem to get it to work.
Maybe what I'm doing isn't possible, but the third section below is how I had the query written for mysql and it's working fine. Answers in code are appreciated! Thanks!
MYSQLI QUERY:
<?php
require("../config.php");
if ($stmt = $mysqli->prepare("SELECT firstname,lastname,spousefirst,phonecell,email,date,contacttype,status FROM contacts WHERE contacttype IN ('Buyer','Seller','Buyer / Seller','Investor') ORDER BY date DESC")) {
$stmt->execute();
$stmt->bind_results($firstname,$lastname,$spousefirst,$phonecell,$email,$date,$contacttype,$status);
while ($stmt->fetch())
{
echo ''.$firstname.' '." ".' '.$lastname.' '.",".' '.$spousefirst.' '.",".' '.$phonecell.' '.",".' '.$email.' '.",".' '.$date.' '.",".' '.$contacttype.' '.",".' '.$status.'</br>';
}
$stmt->close();
}
$mysqli->close();
?>
WHAT I'M TRYING TO COMBINE THE ABOVE WITH:
if (($_GET['date'] == 'today'))
{
$sql = "SELECT * FROM contacts WHERE contacttype IN ('Buyer','Seller','Buyer / Seller','Investor') AND date = DATE(NOW()) ORDER BY date DESC";
}
WHAT I HAD BEFORE WITH MYSQL THAT WORKS:
<?php
require("../config.php");
$sql = "SELECT * FROM contacts WHERE contacttype IN ('Buyer','Seller','Buyer / Seller','Investor') AND status = 'New' ORDER BY date DESC";
if (($_GET['date'] == 'today'))
{
$sql = "SELECT * FROM contacts WHERE contacttype IN ('Buyer','Seller','Buyer / Seller','Investor') AND date = DATE(NOW()) ORDER BY date DESC";
}
?>