Jump to content

How to retrieve/display database image - in an already complicated query?


JTapp

Recommended Posts

**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>");

}

?>

 

 

 

Link to comment
Share on other sites

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']

Link to comment
Share on other sites

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>";

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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.