View Full Version : Query Results Printing Error

10-29-2007, 08:32 PM
This seems to be a weird glitch in the return of the data. The query runs fine and it dumps the data into the array appropriately, however it wont print the result set correctly. I put in a couple of debug tools and found that its only recognizing the first 5 results, but yet when I do a print_r it prints all of the contents its supposed to have.

$connection = mysqli_connect("host", "user", "pass");

$printer = $_GET['p'];

if( mysqli_select_db($connection, "database") ) {
$query = "SELECT DISTINCT p.part_id, p.number, p.description FROM parts_printer AS pp LEFT JOIN parts AS p ON pp.part_id = p.part_id WHERE pp.printer_id = '".$printer."' ORDER BY p.number ASC";
if( $result = mysqli_query($connection, $query) ) {

$status1thumb = array();
$status1nothumb = array();

while( $row = mysqli_fetch_assoc($result) )
$status1thumb[] = array(
'ID' => $row['part_id'],
'NUM' => $row['number'],
'DESC' => $row['description'],
echo "query error";
else {
echo "connection error ";

<title>Parts Verification</title>
<style type="text/css">
table {
margin: 1em;
margin-top: 0;
border-left: 1px solid #000;
border-top: 1px solid #000;
th,td {
border-right: 1px solid #000;
border-bottom: 1px solid #000;

// Print the Results
printf("Query: %s \n", $query);

if( !empty($status1thumb) ) {
echo "<table><caption>Verified w/ Image length: ". strlen($status1thumb) ."</caption>\n\t<tr>\n";
echo "\t\t<th>Number</th>\n";
echo "\t\t<th>Description</th>\n";
echo "\t\t<th>Preview</th>\n\t</tr>\n";

for($i=0; $i<strlen($status1thumb); $i++)
echo "\t<tr>\n";
echo "\t\t<td title='".$status1thumb[$i]['ID']."'>".$status1thumb[$i]['NUM']."</td>\n";
echo "\t\t<td>".$status1thumb[$i]['DESC']."</td>\n";
echo "\t\t<td><img src='/images/parts/thumbnails/tn_".$status1thumb[$i]['NUM'].".jpg' alt='".$status1thumb[$i]['NUM']." Preview'></td>\n";
echo "\t</tr>\n";
echo "</table>";




the string length of the array should be 1096 not 5

10-29-2007, 09:27 PM
I'll take a closer look at it, but can you clear one thing up first--
How does the array have a string length? Would not count() serve your purposes better?

10-29-2007, 10:42 PM
that did it :)) what a brain fart ... lol thx

10-30-2007, 03:56 AM
Hey... glad when it's an easy problem to fix :D