Jump to content

Add to this Code ?


Miss-Ruth

Recommended Posts

how to bring in the relevant image with it (from db)?

 

<?php
$link = mysql_connect("localhost","aabbcc","aabbcc1");
mysql_select_db("abcd");

$query = 'SELECT * FROM aabb';
$results = mysql_query($query);
$query = "SELECT * FROM aabb WHERE identity = '$SomeVar'";
$results = mysql_query($query);
if($line = mysql_fetch_assoc($results))
{
echo $line["email"];
}
mysql_close($link);
?>

 

 

Link to comment
Share on other sites

Once again Miss-Ruth you need to provide a bit more explanation, what exactly are you trying to achieve, what is the expected outcome, what errors are you getting. Are you trying to retrieve the path to an image that you have stored in your database? What does your table look like (columns).

 

ILMV

Link to comment
Share on other sites

With respect Miss-Ruth, did you not read ILMV's post?

 

Without further information it's going to be very difficult to help.  You currently have:

 

echo $line["email"];

 

You could quite easily do:

 

echo '<img src="'.$line["image"].'" alt="Some Image" />';

 

But as ILMV said, without further information pertaining to your database it's hard to say whether the above will work or is even what you want to achieve.

 

Hope this helps.

Link to comment
Share on other sites

My Apologies ILMV!  :shy: I was tired in trying to figure this out since I'm NOT a php girl.

 

On the other hand Bricktop, THANKS!!! that's the sort of answer I was waiting for.  :D I'll have a go and come back to mark this as ANSWERD.

 

Thanks Guys!!

You are always helpful.

:D

Link to comment
Share on other sites

Yes, but like I said we're unsure of what you're trying to achieve. 

 

The above will echo out your email and then echo an image right next to it.

 

You're probably going to want to add some HTML markup for formatting.

 

But as has already been said, more information will in turn give a better answer!

 

Hope this helps.

Link to comment
Share on other sites

No, I fear asking you to use different words wouldn't help my understanding of your issue, but as I suggested providing more information might.

 

Can you provide:

 

1) Your table structure

2) Your criteria for the image you want to return from the database.

... for example, I want to return all images with the parent_id of 17.

 

Edit: oops, a few minutes behind posting this reply :D ignore if already covered

Link to comment
Share on other sites

Hi Miss-Ruth,

 

$line["image"] is just an example (as we have no information relating to your database structure), but that is the syntax you would use (based on the code you posted) to pull an image from your database (again, assuming you are storing image paths, not an actual image in binary).  If the column in your database holding the image path is called "image" then use $line["image"], if it's something else like "picture" use $line["picture"].

 

"Some Image" is an alt tag, this is HTML markup and is the text which gets displayed when you hover your mouse over an image.

 

Hope this helps.

 

 

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.