Miss-Ruth Posted October 21, 2009 Share Posted October 21, 2009 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/178443-add-to-this-code/ Share on other sites More sharing options...
ILMV Posted October 21, 2009 Share Posted October 21, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/178443-add-to-this-code/#findComment-940996 Share on other sites More sharing options...
Miss-Ruth Posted October 21, 2009 Author Share Posted October 21, 2009 ILMV ---- DID YOU READ MY REQUEST? If you want me to say in other words "how to call an image from db? This is my script. I need to add my requirement in to it" Quote Link to comment https://forums.phpfreaks.com/topic/178443-add-to-this-code/#findComment-940999 Share on other sites More sharing options...
Bricktop Posted October 21, 2009 Share Posted October 21, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/178443-add-to-this-code/#findComment-941001 Share on other sites More sharing options...
Miss-Ruth Posted October 21, 2009 Author Share Posted October 21, 2009 My Apologies ILMV! 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. I'll have a go and come back to mark this as ANSWERD. Thanks Guys!! You are always helpful. Quote Link to comment https://forums.phpfreaks.com/topic/178443-add-to-this-code/#findComment-941003 Share on other sites More sharing options...
Miss-Ruth Posted October 21, 2009 Author Share Posted October 21, 2009 Hello! you mean to have 2 echos? { echo $line["email"]; echo '<img src="'.$line["image"].'" alt="Some Image" />'; } Quote Link to comment https://forums.phpfreaks.com/topic/178443-add-to-this-code/#findComment-941008 Share on other sites More sharing options...
Bricktop Posted October 21, 2009 Share Posted October 21, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/178443-add-to-this-code/#findComment-941011 Share on other sites More sharing options...
ILMV Posted October 21, 2009 Share Posted October 21, 2009 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 ignore if already covered Quote Link to comment https://forums.phpfreaks.com/topic/178443-add-to-this-code/#findComment-941012 Share on other sites More sharing options...
Miss-Ruth Posted October 21, 2009 Author Share Posted October 21, 2009 Thanks Bricktop. One more question. is ["image"] my db field name? is "Some Image" the file name of the image? { echo $line["email"]; echo '<img src="'.$line["image"].'" alt="Some Image" />'; } Quote Link to comment https://forums.phpfreaks.com/topic/178443-add-to-this-code/#findComment-941014 Share on other sites More sharing options...
Bricktop Posted October 21, 2009 Share Posted October 21, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/178443-add-to-this-code/#findComment-941016 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.