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
https://forums.phpfreaks.com/topic/178443-add-to-this-code/
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
https://forums.phpfreaks.com/topic/178443-add-to-this-code/#findComment-940996
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
https://forums.phpfreaks.com/topic/178443-add-to-this-code/#findComment-941001
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
https://forums.phpfreaks.com/topic/178443-add-to-this-code/#findComment-941003
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
https://forums.phpfreaks.com/topic/178443-add-to-this-code/#findComment-941011
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
https://forums.phpfreaks.com/topic/178443-add-to-this-code/#findComment-941012
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
https://forums.phpfreaks.com/topic/178443-add-to-this-code/#findComment-941016
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.