User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 402,954 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,838 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 409 | Replies: 1 | Solved
Join Date: Jul 2006
Posts: 155
Reputation: tefflox is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
tefflox's Avatar
tefflox tefflox is offline Offline
Junior Poster

How to stop iterating through a table?

  #1  
May 14th, 2008
Here is the code. For a short time, I will leave the test results up at superiorminitrucks.com/inventory

Clearly, I need to stop it from displaying the final entry twice..

Thanks in advance..

        <?php

		$db_connection = @mysql_connect("######", "#####", "####");
		
		if (!$db_connection) 
			exit();	
			
		mysql_select_db("tefflox", $db_connection);

		$result = mysql_query("SELECT * FROM trucks");

			while($row = mysql_fetch_array($result)) {
			  if($row['id']){
				$lightbox1 = $row['relpath-box1'];
				$lightbox2 = $row['relpath-box2'];			
				$lightbox3 = $row['relpath-box3'];			
				$lightbox4 = $row['relpath-box4'];
				$primary   = $row['relpath-primary'];
				$gallery1  = $row['relpath-gallery1'];
				$gallery2  = $row['relpath-gallery2'];						
				$gallery3  = $row['relpath-gallery3'];			
				$year      = $row['year'];
				$make      = $row['make'];			
				$model     = $row['model'];			
				$miles     = $row['miles'];
				$comment   = $row['comment'];
				$option1   = $row['option1'];
				$option2   = $row['option2'];
				$option3   = $row['option3'];
				$option4   = $row['option4'];
				$option5   = $row['option5'];
				$option6   = $row['option6'];
				$option7   = $row['option7'];
				$option8   = $row['option8'];
			  }																	

		
        echo("<tr>\n");
        echo("  <td width=\"320\">\n");
        echo("    <a href=\"../inventory/trucks/". $lightbox1 ."\" title=\"\" class=\"smoothbox\" rel=\"inventory/trucks/\"><img src=\"../inventory/trucks/". $primary ."\" alt=\"1\" /></a></td>\n");
        echo("  <td width=\"320\">". $year . " " . $make . " " . $model . "<br/><br/>". $miles ."<br/>". $comment ."<br/><br/>\n");
        echo("    <a href=\"../inventory/trucks/" . $lightbox2 . "\" title=\"\" class=\"smoothbox\" rel=\"inventory/trucks/\"><img style=\"float: left\" src=\"../inventory/trucks/". $gallery1 ."\" alt=\"2\" /></a>\n");
        echo("    <a href=\"../inventory/trucks/" . $lightbox3 . "\" title=\"\" class=\"smoothbox\" rel=\"inventory/trucks/\"><img style=\"float: left\" src=\"../inventory/trucks/". $gallery2 ."\" alt=\"3\" /></a>\n");
        echo("    <a href=\"../inventory/trucks/" . $lightbox4 . "\" title=\"\" class=\"smoothbox\" rel=\"inventory/trucks/\"><img style=\"float: left\" src=\"../inventory/trucks/". $gallery3 ."\" alt=\"4\" /></a>\n");          
        echo("  </td>\n");
        echo("  <td>". $option1 ."<br/>". $option2 ."<br/>". $option3 ."<br/><br/>". $option4 ."<br/>". $option5 ."<br/>". $option6 . "<br/>". $option7 ."<br/>". $option8 ."</td>\n");
        echo("</tr>\n\n");				
				
		}
	
		
		mysql_close($db_connection);
		        
        ?>
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MySQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the MySQL Forum

All times are GMT -4. The time now is 6:35 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC