0

Sorry if I am not too clear..

Okay so what I have is a web app that shows all the fleet vehicles for my company.I am pulling the information from my database and what I want is to insert and image for the "support van" so that when it is displayed on my app that the image is pulled from the database, I am not sure about Blob data or anything so a clear instruction would be really helpful

here is my master query-Not the "support vans" query ill post that under this one

Maaster-query

 SELECT
   vi.id as 'VehicleId', 
   vi.class_type as 'VehicleClass',
   vi.registration_number as 'VehicleRegistrationNumber',
   vr.role_name as 'VehicleRole',
   vm.name as 'VehicleMake',
   vmo.name as 'VehicleModel',
   ud.name as 'Depot location'

 FROM 
   unify_rebuild.vehicle_information as vi
 LEFT JOIN 
   unify_rebuild.vehicle_role as vr
  ON
   vi.unit_role = vr.role_id
 LEFT JOIN
   unify_rebuild.vehicle_manufacturer as vm
  ON
   vi.make = vm.id
 LEFT JOIN
   unify_rebuild.vehicle_model as vmo
  ON
   vi.model = vmo.id
 LEFT JOIN
   unify_rebuild.unify_depot as ud
  ON
   vi.depot_current_location = ud.id

and here is the support van query-

 SELECT
   vi.id as 'VehicleId', 
   vi.class_type as 'VehicleClass',
   vi.registration_number as 'VehicleRegistrationNumber',
   vr.role_name as 'VehicleRole',
   vm.name as 'VehicleMake',
   vmo.name as 'VehicleModel',
   ud.name as 'Depot location'

 FROM 
   unify_rebuild.vehicle_information as vi
 LEFT JOIN 
   unify_rebuild.vehicle_role as vr
 ON
   vi.unit_role = vr.role_id
 LEFT JOIN
   unify_rebuild.vehicle_manufacturer as vm
 ON
   vi.make = vm.id
 LEFT JOIN
   unify_rebuild.vehicle_model as vmo
 ON
   vi.model = vmo.id
 LEFT JOIN
   unify_rebuild.unify_depot as ud
 ON
   vi.depot_current_location = ud.id

 WHERE vr.role_name='Support Van';

Any questions please leave a comment and thanks in advance for any help

Calvin

  • 2
    In this sort of application, it's common to store image files (probably .jpg files) on your web server's hard drive, store the names of those images in a database column, and use `` tags to show the images in your web app. Have you ruled out this file approach for some reason? If so, please explain. – O. Jones Sep 15 '14 at 11:49
  • Hello. no I haven't ruled it out just not sure how to do it. – Calvin Taylor Sep 15 '14 at 12:57
  • basically I have four sections displaying each of the four different types of vehicles section one- support van. I want to be able to call the image in with the sql query data. I thought i would have to add the image to the database? how would i link the sql query to the actul image? you say an ? – Calvin Taylor Sep 15 '14 at 13:01

2 Answers2

0

Via your cms you upload images to a folder and take their address and save it in database and to show that image you take URL from database and in your image source give that URL of the image I think this link would be helpful for you How to store file name in database, with other info while uploading image to server using PHP?

Community
  • 1
  • 1
Bilal Haider
  • 173
  • 1
  • 3
  • 14
0

Well you can simply record the url of the image into DB as a new row (for ex. vi.imageUrl='http://url-of-image.png').

Then you call that row of the DB and you save it into a variable (you know how to extract values from the DB) for ex: $url_of_img_extracted_from_db is the variable of the image url, then simply you can call it into html with <img src="$url_of_img_extracted_from_db">

I know the code I posted is wrong, it is just an example, you know how to do it ;)

fulmix
  • 15
  • 1
  • 8
  • Can you explain a little more in detail please? not sure about any of this – Calvin Taylor Sep 15 '14 at 14:30
  • Before explaining let me know if I understood correctly, do you want to display an image stored in DB on the website, right? – fulmix Sep 15 '14 at 15:24
  • Ok. so you can store the url of the image in one row of the DB, then simply inside src="" you put the variable from the extracted url image value from the DB. – fulmix Sep 16 '14 at 12:58