Results 1 to 4 of 4

Thread: Query Results Printing Error

  1. #1
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default Query Results Printing Error

    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.



    Code:
    <?php
    	$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'],
    				);
    			}
    			mysqli_free_result($result);
    			mysqli_close($connection);
    		}
    		else 
    		{ 
    			echo "query error"; 
    		}
    	}
    	else {
    		echo "connection error ";
    	}
    ?>
    
    <html>
    <head>
    	<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;
    }
    </style>
    </head>
    <body>
    
    <?
    	// 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>";
    
    			print_r($status1thumb);
    		}
    ?>
    
    </body>
    </html>
    // EDIT

    the string length of the array should be 1096 not 5
    Last edited by boogyman; 10-29-2007 at 10:41 PM.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    that did it ) what a brain fart ... lol thx

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Hey... glad when it's an easy problem to fix
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •