html - MySQL Database store image url and php page display it? -
i wondering if there’s way store image url in database unique numeric id, , php page display image getting data (the image url) database , displaying user on image.php page?
an example of be: - having image url http://www.example.com/images/image10.jpg (where url stored in database, alongside id of 10) - having image.php page retrieves image url database , displays image on same page (the image.php page) (and doesn’t redirect image url) - example result being image.php?id=10 image.php file source image url database image id of 10 (using example: www.example.com/images/image10.jpg) , display (so viewing image if viewing www.example.com/images/image10.jpg instead url http://www.example.com/image.php?id=10)
is there way this? i'm new php , mysql not code - trying experiment :)
thanks in advance!
edit: think people getting confused bad description (sorry abot that). i've noticed in answers have included actual image url in code - dont understand why though.
example of how i'd work:
my table have these feilds: img_id img_url
the image.php file img_url table using id on end of image.php url. example: - image.php?id=10 - image.php file use id (which 10), , display image retreiving img_url (which be: www.example.com/images/image10.jpg) table , displaying - image id img_id in table. - image.php?id=12 - image.php file use id (which 12) , display image retreiving img_url (which be: www.example.com/images/image12.jpg) table , displaying - image id img_id in table.
you can try this:
//file: image.php?id=10 //you query $img = 'http://example.com/sample.jpg'; // image path database $getinfo = getimagesize($img); header('content-type: ' . $getinfo['mime']); readfile($img);
Comments
Post a Comment