Skip to content

Instantly share code, notes, and snippets.

@R2D2-05
Created May 22, 2015 18:58
Show Gist options
  • Save R2D2-05/78d81566e4bf0eafd1fa to your computer and use it in GitHub Desktop.
Save R2D2-05/78d81566e4bf0eafd1fa to your computer and use it in GitHub Desktop.
<?php
function status_total($customer, $system){
$sql_customer = "SELECT * FROM `Customer` WHERE Cust_Name = '$customer' LIMIT 0,1";
$customer_selection = mysqli_query($conn,$sql_customer);
$customer_row = mysqli_fetch_assoc($customer_selection);
$env_lines = $customer_row["Env_Lines"];
$cust_id = $customer_row["Cust_ID"];
$sql_last_records = "SELECT * FROM $system WHERE Cust_ID = $cust_id ORDER BY Time DESC LIMIT $env_lines";
$record_selection = mysqli_query($conn, $sql_last_records);
$result = mysqli_fetch_all($record_selection, MYSQLI_ASSOC);
$states = array_column($result, "Stat");
if($states == array_fill(0, count($states), "Run")) {
echo "Success";
} else
echo "Fail";
}
?>
@R2D2-05
Copy link
Author

R2D2-05 commented May 22, 2015

this code works if i use it as a whole in a page but if I make it a function it doesnt work. It doesnt get the variables that are given, even if I type it in plain text. Where did I make a mistake?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment