Hi everyone.

Could someone assist me with a problem I have. I want to display images in a folder.(image/). I have my MySQL table with my images location.(images/test.jpg) etc.
I also have a legend_id where I specified id's (id_1, id_2, id_3) This is linked to cars.

If I search according to legend_id I want to display all images that's got the same legend_id.

Hope it makes sense.

Thanks in advance.

Recommended Answers

All 8 Replies

Member Avatar for rajarajan2017

Where is your code?

Where is your code?

Hi There.

Here is my display.php code.

<?php session_start(); ?>
<html>
	<body>
		<table border='1' cellpadding='1' cellspacing='0'>
<?php
	require_once 'include/config.php';
	require_once 'include/opendb.php';
	
	$data = $_POST['carmodel'];
	
?>
<?php

$files = glob("image/$data.jpg");

for ($i=0; $i<count($files); $i++) 
{ 
$num = $files[$i];"<br/>"; 
echo '<br><tr><td>'.$data.'<br><img src="'.$num.'" height="150" width="150" alt="'.$num.'" />'."</td><td></td><td></td></tr><br/>"; 

?>
<?php

	$SQLSEL = "SELECT * FROM dealer_vehicles where manufac_legend='$data'";
	$SQLRESULT = mysql_query($SQLSEL)or die(mysql_error());
	$SQLROWS = mysql_num_rows($SQLRESULT)or die(mysql_error());
	
	for($i=0; $i < $SQLROWS; $i++){
	$deal_name = mysql_result($SQLRESULT, $i, 'DEALER_NAME');
	$milage = mysql_result($SQLRESULT, $i, 'MILEAGE');
	$eng_nr = mysql_result($SQLRESULT, $i, 'ENGINE_NO');
	$veh_img1 = mysql_result($SQLRESULT, $i, 'VEH_IMG_ONE');
	$reg_nr = mysql_result($SQLRESULT, $i, 'REG_NO');
	$veh_col = mysql_result($SQLRESULT, $i, 'COLOR');
	$ask_price = mysql_result($SQLRESULT, $i, 'ASKING_PRICE');
	$demo_veh = mysql_result($SQLRESULT, $i, 'DEMO_VEH');
	$trade_veh = mysql_result($SQLRESULT, $i, 'TRADE_VEH');	
	$model_legend = mysql_result($SQLRESULT, $i, 'manufac_legend');

?>
				<tr>
					<td>Dealer Name</td>
						<td>:</td>
							<td><?php echo $deal_name;?></td>
				</tr>
				<tr>
					<td>Mileage</td>
						<td>:</td>
							<td><?php echo $milage;?></td>
				</tr>
					<td>Engine Nr</td>
						<td>:</td>
							<td><?php echo $eng_nr;?></td>
				</tr>
					<td>Vehicle Image</td>
						<td>:</td>
							<td><?php echo $veh_img1;?></td>
				</tr>
					<td>Reg Nr</td>
						<td>:</td>
							<td><?php echo $reg_nr;?></td>
				</tr>
					<td>Cehicle Color</td>
						<td>:</td>
							<td><?php echo $veh_col;?></td>
				</tr>
					<td>Asking Price</td>
						<td>:</td>
							<td><?php echo $ask_price;?></td>
				</tr>
					<td>Demo Vehicle</td>
						<td>:</td>
							<td><?php echo $demo_veh;?></td>
				</tr>
					<td>Tradein</td>
						<td>:</td>
							<td><?php echo $trade_veh;?></td>
				</tr>
					<td>Model Legend</td>
						<td>:</td>
							<td><?php echo $model_legend;?></td>
				</tr>
<?php			
	}
}
?>
		</table>
	</body>
</html>

This is the Index Page where I select every vehicle that is located under the selected id.

<tr>
		<td>
			<fieldset style='color:black;border:1px solid #0C4382'>
				<legend style='font-weight:bold;color:Maroon;font-size:12pt'>Search</legend>
<?php	 
					echo "<form name=sel action='display.php' method='post' target='_blank'>";
						echo "Manufacture <font id=manufac_make><select name='carmodel' onChange='submit();'>";
							echo "<option value='0'>Please Select</option>" ;
					echo "</select></font><br>"; 
						echo "Car Model <font id=manufac_model><select>";
								echo "<option value='0'>Select Model</option>" ;
					echo "</select></font>";
					
?>	 
			</fieldset>
		</td>
	</tr>

I want to be able to display all the vehicles located under the image/ directory.
The 3 tables I'm using.
Manufac_Make

----------------
 Field
----------------
 manuf_id
 manuf_make
 manuf_link
 manufac_legend

Manufac_Model

Field
----------------
 manuf_id
 manuf_model
 manuf_link
 manufac_legend

and Lastly Dealer_Vehicles

dlr_vehicle_id
 DEALER_NAME
 MILEAGE
 ENGINE_NO
 MANUF_NAME
 MODEL_NAME
 REGION_NAME
 VEH_IMG_ONE
 VEH_IMG_TWO
 VEH_IMG_THREE
 VEH_IMG_FOUR
 VEH_IMG_FIVE
 DUMP_DATE
 RMI_NO
 REG_NO
 MEAD_CODE
 STOCK_NO
 COLOR
 STATUS
 REG_DATE
 ASKING_PRICE
 P_KEY
 PRICE_RANGE
 TOP10_COMMENT
 TOP10_NUMBER
 DATE_INTO_STOCK
 COST_PRICE
 STAND_IN_PRICE
 STOCK_DAYS
 SPECIAL_VEH
 DEMO_VEH
 TRADE_VEH
 VIN_NO
 DLR_CODE
 ACTUAL_STOCK_DAYS
 VEHICLE_IMG
 manufac_legend

Thanks for your assistance.

Regards

Member Avatar for rajarajan2017
$files = glob("image/$data.jpg");

$data.jpg Is it make sense? Path should be "images/*.*" or "images/data.jpg" r8?

Member Avatar for rajarajan2017

Okay, I am confused, you just want to load the image and their relevant datas according to the lengend id r8. Then

i) Make a query to fetch the records including image path according to the lengendid.
ii) Then the load the image and display relevant detials.

Okay, I am confused, you just want to load the image and their relevant datas according to the lengend id r8. Then

i) Make a query to fetch the records including image path according to the lengendid.
ii) Then the load the image and display relevant detials.

Hi.

Thanks for the quick reply. Can you please assist me with the code if it's not to much to ask. I think my code is where the whole problem begins.

Thanks Allot.

Cheers

Member Avatar for rajarajan2017

dealer_vehicles has the image path field right? which one is that?. There is no need of files concept when you have path in your database.

With your loop directly add the row

echo '<br><tr><td>'.$data.'<br><img src="'.$num.'" height="150" width="150" alt="'.$num.'" />'."</td><td></td><td></td></tr><br/>";

and pass the src=your row data directly because it is a path right, instead of the .$num

dealer_vehicles has the image path field right? which one is that?. There is no need of files concept when you have path in your database.

With your loop directly add the row

echo '<br><tr><td>'.$data.'<br><img src="'.$num.'" height="150" width="150" alt="'.$num.'" />'."</td><td></td><td></td></tr><br/>";

and pass the src=your row data directly because it is a path right, instead of the .$num

Hi.

I have 3 different tables. manufac_make, manufac_model and dealer_vehicles.
My index page loads data from manufac_make into a drop down menu. Then my second drop down menu is populated. When I submit data it goes to new page where I get the $data and $num variables.

Example : I select Audi then in second drop down menu I select A3. My next page will display the A3 only and not the full image path.

I want to be able to Select Audi and then A3, then it must search my DB for every entry for Audi A3 and display all the found results and images.

Thank Allot for your pacients.

Hi.

I have 3 different tables. manufac_make, manufac_model and dealer_vehicles.
My index page loads data from manufac_make into a drop down menu. Then my second drop down menu is populated. When I submit data it goes to new page where I get the $data and $num variables.

Example : I select Audi then in second drop down menu I select A3. My next page will display the A3 only and not the full image path.

I want to be able to Select Audi and then A3, then it must search my DB for every entry for Audi A3 and display all the found results and images.

Thank Allot for your pacients.

Hi Raja

I understand what you are saying, Will check later. Thanks for all you patients.

Regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.