OK, I see what you want now... Sorry, but it just wasn't clear without the details fo the image or added thread...
Personally.... I would dump the values into an array. Then, I would cycle through array in one row to output the graph images.
Then I would cycle through the array again to create the second row below that one that outputs the numbers...
Something like this.
This is all conceptual and untested because I am not at home with my PHP, but should help point you on your way...
NOTE You need to modify this to complete things like your img tag and whatnot. I quickly put this all together for concept only and not for complete functionality.
while($rows=mysql_fetch_array($result)){
$myarray($rows['id']) = $rows['views'];
}
echo '<table>';
echo '<tr>';
foreach($myarray as $k=>$v) {
echo '<td><img src.... height="$v"></td>';
}
echo '</tr>';
echo '<tr>';
foreach($myarray as $k=>$v) {
echo '<td>$k</td>';
}
echo '</tr>';
echo '</table>';