Jump to content

Swapping text to an image


Revolutsio

Recommended Posts

Hi

I have a database with all my game collection on and have the code to display it on a webpage, my problem is in one field called Media, i have the text 'Physical' in it and i would like to change this within PHP to an image of a floppy disk when it displays on the webpage.

Can this be done.

I have done something similar with and if statement to display a 'tick' instead of a 1.

 

IF
	( owned = 1, '✔', 'X' ) AS owned,
	IF
		( completed = 1, '✔', ' ' ) AS completed

i would like to do this as above rather than adding it to the MySQL database - the floppy image is on my computer in a folder called Images.

Link to comment
Share on other sites

Hi thank you for your reply, I have tried the above code and I get a error

Parse error: syntax error, unexpected 'Images' (T_STRING) 

here is my Select code

<?php

		$sql = "SELECT
	ID,
	GAME,
	YEAR,
	PLATFORM,
	PUBLISHER,
	Owned,
	COMPLETED,
	Media,
	Launcher,

	IF(Media='Physical', '<img src="Images/floppy.png"">', Media) as Media

FROM
	games;";

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.