I'm having an issue comparing a value in an array with the previous value in the array and then performing the appropriate operation. Some values are identical so I want to strip them out.
What I am trying to have it do is interrogate the variable against the previous value and if they are equal display everything else except said value.
Here is my code. I apologize if its difficult to read. I'm self taught and I do my best...
<?php
// Get Variables from dept.php
$location = $_GET['location'];
$dept = $_GET['dept'];
// Connect to Database
$connect = mysql_connect('localhost', 'UserName', 'Pass');
mysql_select_db('database', $connect);
// Create Recordset
$iso_sql = " SELECT * FROM `a_qa-iso_data`, `a_qa-iso_category` WHERE `a_qa-iso_data`.Article_Numbers = `a_qa-iso_category`.Article_No AND `a_qa-iso_data`.$location = 1 AND `a_qa-iso_data`.$dept = 1 ORDER BY `a_qa-iso_data`.Article_Numbers, `a_qa-iso_data`.Filename ASC;";
$iso_results = mysql_query($iso_sql, $connect) or die(mysql_error());
$rows_iso_results = mysql_num_rows($iso_results);
// Loop Results
while ($iso_array = mysql_fetch_array($iso_results)) {
$article = $iso_array['Article_Numbers'];
$title = $iso_array['Title'];
$link = $iso_array['Link'];
$class = $iso_array['Class'];
$target = $iso_array['Target'];
$filename = $iso_array['Filename'];
$header = "<h4>$article - $title</h4>";
$iso = "<a href=\"$link\" class=\"$class\" target=\"$target\">$filename</a>";
// Display
$next = prev($iso_array);
if ($next['Article_Numbers'] === $article) {
echo "$iso";
}
else {
echo "$header $iso";
}
}
?>
So in short, I am looking for something like:
$article - $title
-$iso
$article - $title
-$iso
-$iso
$article - $title
-$iso
-$iso
-$iso
$article - $title
-$iso
Anyhow any help would be appreciated. I apologize as well if this has been asked before however, I've spent quite a bit of time looking and what I have found didn't seem to be as informative as I would have hoped.
mysql_*functions. They're being deprecated. Instead use PDO (supported as of PHP 5.1) or mysqli (supported as of PHP 4.1). If you're not sure which one to use, read this article.