JTapp Posted February 17, 2008 Share Posted February 17, 2008 **Please forgive my overly complicated beginner's code and language** Situation: My query currently pulls from two tables using $metode LIKE '%$search%' I now have a new, third table that includes the same UniqueID as the other two. I do not need to include it in the search function, but this new table is designed to store images. Problem: I need to retrieve the image (unique to my ID field) and display it on my webpage. At this point my stomach turns when I look at my existing code. But I have to somehow add to my code to get this done. Any help is greatly appreciated. The new table is called 'tblLodgePics' It currently has the following fields in it: id varchar(15), description varchar(255), bin_data LONGBLOB, filename varchar(50), filesize varchar(50), filetype varchar(50), link varchar(255), shownno integer(5), clickcount integer(5), lngLodgeID (this is my unique field that can be found in the other 2 tables) Here is my current code to view it in (unformatted) action go to: http://www.la-mason.com/search15.html and search for 'Lodge Name' = "Abbeville". I basically need to embed Abbeville's photo into this page: //query details table begins $query = mysql_query("SELECT tblLodges.strLodgeName, tblLodges.intLodgeNumber, tblLodges.strDistrictName, tblLodges.strLodgeWEB, tblLodges.strLodgeCounty, tblLodges.dtChartered, tblLodges.strLodgeAddress, tblLodges.strLodgeAddress2, tblLodges.strLodgeLocationCity, tblLodges.strLodgeLocationState, tblLodges.strLodgeLocationZip, tblLodges.strLodgeEmail, tblLodges.strLodgePhone, tblLodges.strLodgeFax, tblLodges.strDrivingDirectons, tblLodges.dtMeetingTime, tblLodges.dtMealTime, tblLodges.strFloorSchool, tblLodges.strLodgeNews, tblOfficers.strFirstName, tblOfficers.strLastName FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' GROUP BY tblLodges.strLodgeName LIMIT 0, 50"); while ($row = @mysql_fetch_array($query)) { $variable1=$row["strLodgeName"]; $variable2=$row["intLodgeNumber"]; $variable3=$row["strDistrictName"]; $variable4=$row["strLodgeWEB"]; $variable5=$row["strLodgeCounty"]; $variable6=$row["dtChartered"]; $variable7=$row["strLodgeAddress"]; $variable8=$row["strLodgeAddress3"]; $variable9=$row["strLodgeLocationCity"]; $variable10=$row["strLodgeLocationState"]; $variable11=$row["strLodgeLocationZip"]; $variable12=$row["strLodgeEmail"]; $variable13=$row["strLodgePhone"]; $variable14=$row["strLodgeFax"]; $variable15=$row["strDrivingDirectons"]; $variable16=$row["dtMeetingTime"]; $variable17=$row["dtMealTime"]; $variable18=$row["strFloorSchool"]; $variable19=$row["strLodgeNews"]; //table layout for results print ("<tr>"); echo '<p><h3>' . $variable1 . '</h3></p><p>' . $variable2 . '</p>'; echo '<p>' . $variable3 . '</p>' . $variable4 . '</p>'; echo '<p>' . $variable5 . '</p>' . $variable6 . '</p>'; echo '<p>' . $variable7 . '</p>' . $variable8 . '</p>' . $variable9 . '</p>' . $variable10 . '</p>' . $variable11 . '</p>'; echo '<p>' . $variable12 . '</p>' . $variable13 . '</p>' . $variable14 . '</p>'; echo '<p>' . $variable15 . '</p>'; echo '<p>' . $variable16 . '</p>' . $variable17 . '</p>' . $variable18 . '</p>'; echo '<p>' . $variable19 . '</p>'; print ("</tr>"); } ?> </tr> </table> <hr width=75% align=center size=4> <p><strong>Roster of Lodge Officers </strong></p> <p> <?php //query details table begins $query = mysql_query("SELECT tblLodges.strLodgeName, tblLodges.intLodgeNumber, tblLodges.strDistrictName, tblLodges.strLodgeLocationCity, tblLodges.strLodgeLocationZip, tblLodges.strLodgeCounty, tblOfficers.strFirstName, tblOfficers.strLastName, tblOfficers.BusinessPhone, tblOfficers.PersEmail FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID WHERE $metode LIKE '%$search%' LIMIT 0, 50"); $results=mysql_query($query); echo "<table border='1'> <tr> <th>Officer First</th> <th>Officer last</th> <th>Officer Email</th> <th>Officer Phone</th> </tr>"; // while ($row = mysql_fetch_array($query)) { $variable1=$row["strFirstName"]; $variable2=$row["strLastName"]; $variable3=$row["PersEmail"]; $variable4=$row["BusinessPhone"]; //table layout for results print ("<tr>"); echo "<td class=\"td_id\"><h3>$variable1</h3></td>\n"; echo "<td class=\"td_id\"><h3>$variable2</h3></td>\n"; echo "<td class=\"td_id\"><h3>$variable3</h3></td>\n"; echo "<td class=\"td_id\"><h3>$variable4</h3></td>\n"; echo "<td class=\"td_id\"><h3>$variable5</h3></td>\n"; print ("</tr>"); } ?> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted February 17, 2008 Share Posted February 17, 2008 Which query in your code are you trying to add this to? You have two queries in your supplied code. If it is the first one, try this: SELECT tblLodges.strLodgeName, tblLodges.intLodgeNumber, tblLodges.strDistrictName, tblLodges.strLodgeWEB, tblLodges.strLodgeCounty, tblLodges.dtChartered, tblLodges.strLodgeAddress, tblLodges.strLodgeAddress2, tblLodges.strLodgeLocationCity, tblLodges.strLodgeLocationState, tblLodges.strLodgeLocationZip, tblLodges.strLodgeEmail, tblLodges.strLodgePhone, tblLodges.strLodgeFax, tblLodges.strDrivingDirectons, tblLodges.dtMeetingTime, tblLodges.dtMealTime, tblLodges.strFloorSchool, tblLodges.strLodgeNews, tblOfficers.strFirstName, tblOfficers.strLastName, tblLodgePics.link FROM tblLodges LEFT JOIN tblOfficers ON tblLodges.lngLodgeID = tblOfficers.lngLodgeID LEFT JOIN tblLodgePics ON tblLodgePics.lngLodgeID = tblLodges.lngLodgeID WHERE $metode LIKE '%$search%' GROUP BY tblLodges.strLodgeName LIMIT 0, 50 And of course to get the value for the image, you would just echo out $row['link'] Quote Link to comment Share on other sites More sharing options...
JTapp Posted February 17, 2008 Author Share Posted February 17, 2008 Thanks. I'm working on this.. but I have to fix another .php which is add picture to database. I'll let you know. Appreciating your time Quote Link to comment Share on other sites More sharing options...
JTapp Posted February 18, 2008 Author Share Posted February 18, 2008 Ok, it is communicating with the new table and my link is showing up. But I don't think I wrote my echo right... ? echo $row['link']; Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted February 18, 2008 Share Posted February 18, 2008 Ok, it is communicating with the new table and my link is showing up. But I don't think I wrote my echo right... ? echo $row['link']; Well, does that make the link show up? If so...then whats the problem? What does it echo out? If it only prints out the url and you want it to be a link, then you can do this: <?php echo "<a href='{$row['link']}'>Link</a>"; Quote Link to comment Share on other sites More sharing options...
JTapp Posted February 18, 2008 Author Share Posted February 18, 2008 Oh - sorry my communication gets worse after lack of sleep. Yes, the link is showing up just fine. I'm actually trying to display or embed the image.. not the link. Thanks Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted February 18, 2008 Share Posted February 18, 2008 I'm still a little confused. So the link is a url to an image? So maybe you want this.... <?php echo "<img src='{$row['link']}'>"; Quote Link to comment Share on other sites More sharing options...
JTapp Posted February 18, 2008 Author Share Posted February 18, 2008 You absolutely rock! I'm going to bed! My health and well being appreciates it. Thank you very much. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted February 18, 2008 Share Posted February 18, 2008 No problem Please click topic solved this time, haha. Also, for future reference, there is no need to make multiple topics for virtually the same thing. Quote Link to comment Share on other sites More sharing options...
JTapp Posted February 18, 2008 Author Share Posted February 18, 2008 Yeah.. I figured you saw my latest posting. But I noticed you were offline and didn't know if I would ever hear from you again. Seems like an old posting with responses might not get any more attention - I don't know. Regarding "solving" the posting.. the option to "click here" to solve is now gone. I've got a couple of postings like that.. I don't know how to get rid of them.. Thanks again. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted February 18, 2008 Share Posted February 18, 2008 Okay...I either got hacked or a moderator went in and edited my signature. I'm not sure why they would change all my links to go to "darkmindz.com", so I'm guessing I got hacked. I guess I'm off to change my password. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted February 18, 2008 Share Posted February 18, 2008 Okay...I either got hacked or a moderator went in and edited my signature. I'm not sure why they would change all my links to go to "darkmindz.com", so I'm guessing I got hacked. I guess I'm off to change my password. Okay...nevermind. Everyone's signature links seem to be leading to "darkmindz". Strange. Quote Link to comment Share on other sites More sharing options...
Stooney Posted February 18, 2008 Share Posted February 18, 2008 Probably the group that caused phpfreaks to take all but the forums down. Quote Link to comment Share on other sites More sharing options...
JTapp Posted February 23, 2008 Author Share Posted February 23, 2008 pocobueno1388 - You helped me with this query a couple of days ago and I was wondering if you had a minute take a look at my other post. Its a mysql_fetch_array error message..in the same php code... I had to change some things on the top part of the code - but that area of hasn't changed. I'm quite puzzled... http://www.phpfreaks.com/forums/index.php/topic,183774.msg821963.html#msg821963 Quote Link to comment 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.