The company database has duplicate entries for ID due to different locations so I'm trying to return the database queries on the website by ID # AND zip matches. I can get the the code to query the database and not return an error but it won't return the values in the results(only blank entries) from the row it found.
Any ideas?
$mysqli = new mysqli($host, $user, $password, $dbname);
if (mysqli_connect_errno()) {
printf("Connect failed: %s
", mysqli_connect_error());
exit();
}
$searchTerm = $_GET['term']; // GET the search term submitted by the form
$zip = $_GET['term1'];
$customerNumber = '';
$progID = '';
$balance = '';
$sql = "Select cust_no, zip From teecust where cust_no=? and zip=?";
// Create the prepared statement
if($stmt = $mysqli->prepare($sql)){
$stmt->bind_param("ss", $searchTerm, $zip); // bind the search term to the query where the '?' once was
if(!$stmt->execute()){ // run the query
echo $mysqli->error;
};
$stmt->bind_result($customerNumber, $progID, $balance); // retrieve results into variables
while($stmt->fetch()){ // loop through results
// You now have the result in $customerNumber, $progID, and $balance - do what you want with it
echo "Customer number: " . $customerNumber . "<br>Date last updated on: " . $progID . "<br> Balance: <strong>$" . $balance . "</strong> ";
}
$stmt->close();
}
else{
echo $mysqli->error;
}
?>