I have this php code which looks like this:
Code: Select all
$sql = ......
$result = mysql_query($sql,$connection)
or die("Couldn't execute SELECT query");
while ($row = mysql_fetch_array($result)) {
......
}
Code: Select all
while ($row = mysql_fetch_array($result)) {
......
if (ID for next row/record != ID for this row/record) {
do this
}
}
[syntax]
Product name 1
Product name 1
<break line or something else>
Product name 2
Product name 2
Product name 2
Product name 2
<break line or something else>
Product name 3
...
[/syntax]
I almost got the solution , but the very last record for my query is always missing using this code:
Code: Select all
$current_row=mysql_fetch_array($result); //read $current_row
while ($next_row = mysql_fetch_array($result)) { //read $next_row
......
if ($current_row['id']!=$next_row['id']) { //compare it
.....
.....
}
$current_row=$next_row; //$next_row become current_row on next step
}
Thank You!