
Originally Posted by
froger
updated my original post.
Which makes it confusing, since you're making a new request by changing the original. On a site like SO, updating the original post is the correct action, but this is a forum; it's fine (rather, preferred) to write updates in new posts.

Originally Posted by
froger
For some reason, the above statement doesn't work as intended for me.
What happens instead, and how is it different than what you want? When describing a problem, state the behavior you expect/desire and what you get.
To break up the result set into lines, you can check for when the y-value changes.
PHP Code:
<div>
<div class="line">
<?php
$prevY = 1;
// $db is a PDO instance
// DB access should be performed in a separate layer
foreach ($db->query('SELECT x, y, z, textimage FROM test WHERE x BETWEEN 1 AND 100 AND y BETWEEN 1 AND 65 ORDER BY y, x') as $piece) {
if ($prevY != $piece['y']) {
?>
</div>
<div class="line">
<?php
}
echo $piece['textimage'];
$prevY = $piece['y'];
}
?>
</div>
</div>
As noted in the comment, DB access should be isolated in a data access layer. The query would then become a prepared statement so that the ranges of x and y values can be altered.
PHP Code:
$imgQuery = $db->prepare('SELECT x, y, z, textimage
FROM test
WHERE x BETWEEN :xmin AND :xmax
AND y BETWEEN :ymin AND :ymax
ORDER BY y, x');
$imgQuery->execute(array(':xmin' => 1, ':xmax' => 100, ':ymin' => 1, ':ymax' => 65 ));
What do the assembled textimage pieces make? A map? ASCII art?