HI Have a field in database which has multiple of the same number in, I have got a query of which works with the field with 1 in but then want it to then go to ++ so if I limit 9 results they will show with this query for all echoed out fields and only one result for naughtyfield =1, naughtyfield=2,naughtyfield3 etc etc up to 9

SELECT * FROM _TABLE WHERE naughtyfield=1 GROUP BY naughtyfield, field2 ORDER BY naughtyfield, field2 ASC LIMIT 9

HOpe some one can help and hope I have explained it OK , Thanks

It may be easier to help if you show some data, and your expected output.

`

$result = $dba->query()->fetchAll(PDO::FETCH_ASSOC);

$dba = null;

$break = 3;

$lineend = $break;


        echo '' . $row['field'] . ' ' . $row['naughtyfield'] . ' ' . $row['field'] . '';



        echo '</ul>
                        </div>
                </div>
                <div class="threeColFooter">
                </div>';

        echo '</div>';

        if(($k + 1) == $break)
        {
                echo '<div class="clear"></div>';

                $break = $break + $lineend;
   $lineend;
        }
}
?>

`

show some data, and your expected output

I didn't mean code. I meant the data that is in your table, and how you want it to look after retrieving it.

data eg

Field Field2 naughtyfield
blar 7 1
blar 5 2
blar 4 3
blar 9 4
blar 6 5
blar 5 6
blar 1 1
blar 2 2
blar 5 3
blar 4 4
blar 6 5
blar 12 6

result

1-1
2-1
3-4
4-4
5-6
6-5

It may be clear to you, but not to me. How do you get from data to result? What's the logic?

Care to share what solved it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.