Hello all. First post from a PHP newbie.

I'm trying to teach myself how to retrieve data from my MySQL databse and have so far managed to get the text retrieval to work. What I'd now like to do, is to get my PHP page to retrieve an image, specifically for my user group (doesn't exist yet, just a series of MySQL tables) to display a logo or picture they (eventually) upload. But, I'm stuck.

I've been trawling the posts and have found a reference to:

<img src="/images/<?=$image_name_here?>">

;[code=php]

But, now i've manged to get my login function working, I want the screen to show the logged-in users logo (which I will create the upload function for later). As my test $user_id are 1 & 2, how do I link the images called 1.gif and 2.gif in my page code, so it shows the correct image, regardless of which is logged in ?? Also, as its a MySQL database, and I quite like having a fast page load, I dont want to add these images into the database, just a link to them which adapts to the user logged in.

I've only been learning how to use PHP for about 6-7 weeks now, in my spare time, so any help you could give me would be great. As I'm still struggling with the syntax.[code=php]

<img src="/images/<?=$image_name_here?>">

;

But, now i've manged to get my login function working, I want the screen to show the logged-in users logo (which I will create the upload function for later). As my test $user_id are 1 & 2, how do I link the images called 1.gif and 2.gif in my page code, so it shows the correct image, regardless of which is logged in ?? Also, as its a MySQL database, and I quite like having a fast page load, I dont want to add these images into the database, just a link to them which adapts to the user logged in.

I've only been learning how to use PHP for about 6-7 weeks now, in my spare time, so any help you could give me would be great. As I'm still struggling with the syntax.[code=php]

But, now i've manged to get my login function working, I want the screen to show the logged-in users logo (which I will create the upload function for later). As my test $user_id are 1 & 2, how do I link the images called 1.gif and 2.gif in my page code, so it shows the correct image, regardless of which is logged in ??
Also, as its a MySQL database, and I quite like having a fast page load, I dont want to add these images into the database, just a link to them which adapts to the user logged in.

I've only been learning how to use PHP for about 6-7 weeks now, in my spare time, so any help you could give me would be great. As I'm still struggling with the syntax.

Recommended Answers

All 2 Replies

I did something similar before, and this is what I did. Put the path into a variable, in this case, $r'uploadedfile'

<?php

echo "<img src=\"http://localhost/cas/uploads/$r[uploadedfile]\"alt=\"\" name=\"\" width=\"100\" height=\"90\" border=\"1\"/></img>";

?>

Thanks very much, will try that later.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.