Created
May 22, 2015 18:58
-
-
Save R2D2-05/78d81566e4bf0eafd1fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?