Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End How To Display Stored Image Using Path? Reply To: How To Display Stored Image Using Path?

#164424
MBM
Participant

I’ve resolved it. I’m working on retreving the images and form data. I need to explain this so sorry for the long post.

In the form table I have the following fields :

id - PK auto incrementing
username - stored as a session when the user logs in
name
species
population
weight
length

In the images table I have the following fields :

id - PK auto incrementing
username - stored as a session when the user logs in
path - path to the image

Both the form data and image data are submitted at the same time and have matching ids. e.g.

The id for the form data for Tiger in $Table_2 is 1
The id for the image path for Tiger in $Table_3 is 1

etc, etc.

If I run this query in mysql admin the records and images match :

Select * from $Table_2 JOIN $Table_3 ON $Table_2.id = $Table_3.id

The problem is I have two queries in my php. One for retrieving and displaying the form data and one for retrieving and displaying the images e.g.

$Link = mysqli_connect($Host, $User, $Password, $Database);
$Query = " Select * from $Table_2 JOIN $Table_3 ON $Table_2.id = $Table_3.id";
if($Result = mysqli_query($Link, $Query)){
while($row = mysqli_fetch_array($Result))
{
php for storing image path as array etc, etc
}

$Link = mysqli_connect($Host, $User, $Password, $Database);
$Query = " Select * from $Table_2 JOIN $Table_3 ON $Table_2.id = $Table_3.id";
if($Result = mysqli_query($Link, $Query)){
while($row = mysqli_fetch_array($Result))
{
php for storing form data as arrays and adding a count etc, etc
}

So when I try the joins above it’s a mess and the form data does not match with the image.

What query do I need to run in order to get the records to match? I have tried the same select statement in both queries and also tried reversing the tables.

Also how do I add an image class around this code?

<td class="tcgimagecell" colspan="5">
<?php echo "<img src='$img_path'>"; ?>
</td>

I would normally use class=”imgsize” but that doesn’t work in this case. Do I add it in the loop here?

<?php foreach( $img_paths as $img_path )
{ ++$i;?>