简体   繁体   English

如何从MySQL列中提取图像以在Web应用程序上显示

[英]How to pull an image from a MySQL column to display on web app

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 好的,现在我有了一个网络应用程序,其中显示了我公司的所有车队车辆。我正在从数据库中提取信息,我想要的是为“支持车”插入图像并在其中显示图像。应用程序,该图像是从数据库中提取的,我不确定Blob数据或其他内容,因此明确的说明将非常有帮助

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 加尔文

通过您的CMS你上传图片到一个文件夹,并把他们的地址,并将其保存在数据库中,并显示出你把URL从数据库和图像来源,像给图像的URL,我认为这个链接会为你有所帮助如何将文件名存储在数据库中,以及使用PHP将映像上传到服务器时的其他信息?

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 '). 好吧,您可以简单地将图像的URL记录为新行(例如vi.imageUrl =' http://url-of-image.png ')到DB中。

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"> 然后调用数据库的该行,并将其保存到变量中(您知道如何从数据库中提取值),例如:$ url_of_img_extracted_from_db是图像url的变量,然后只需将其用<img src="$url_of_img_extracted_from_db">调用为html <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 ;) 我知道我发布的代码是错误的,这只是一个例子,你知道怎么做;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM