I have a while loop that returns X amount of data with the same value X amount of times before it changes to a different value.
// example 121, 121, 121, 121, 113, 113, 113, 113
each value is on its own line so a while loops puts them on the next is it possible to have an if that uses when the value changes ?
some thing like
while($row = $result->fetch_assoc()) {
if ($row["name"] == $row["name"]){
echo "<tr><td>".$row["name"]."</td><td>".$row["combi"]."</td>"
}else{
echo "<td>".$row["combi"]."</td></tr>"
}
}
You just use another variable to stock the last value
<?php
$lastval = 0;
while($row = $result->fetch_assoc()) {
if ($row["name"] != $lastval){
$lastval = $row["name"];
// value has changed
}else{
// Value is the same as the last one
}
}
?>
Don't forget to "ORDER BY name"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With