I was wondering if there’s any way I could store an image URL in a database with a unique numeric id, and a php page display the image by getting data (the image URL) from the database and displaying it to the user on the image.php page?
An example of this would be: - Having the image URL http://www.example.com/images/image10.jpg (where this URL would be stored in the database, alongside an id of 10) - Having an image.php page which retrieves the image URL from the database and displays the image on the same page (the image.php page) (and doesn’t redirect to the image URL) - an example result being image.php?id=10 where the image.php file would source the image URL from the database with an image id of 10 (using my example: www.example.com/images/image10.jpg) and display it (so it would be like viewing the image as if you were viewing www.example.com/images/image10.jpg but instead the URL would be http://www.example.com/image.php?id=10)
Is there any way to do this? I'm new to php and MySQL so not really good with code - trying to experiment :)
Thanks in advance!
Edit: I think people are getting confused by my bad description (sorry abot that). I've noticed in your answers that you have included the actual image URL in your code - I dont understand why though.
EXAMPLE of how I'd like this to work:
My table would have these feilds: img_id img_url
The image.php file would GET the img_url FROM the table using the id on the end of the image.php url. FOR EXAMPLE: - image.php?id=10 - the image.php file would use the id (which is 10), and display the image by retreiving the img_url (which would be: www.example.com/images/image10.jpg) from the table and displaying it - the image id would be img_id in the table. - image.php?id=12 - the image.php file would use the id (which is 12) and display the image by retreiving the img_url (which would be: www.example.com/images/image12.jpg) from the table and displaying it - the image id would be img_id in the table.