Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8954271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:17:07+00:00 2026-06-15T14:17:07+00:00

So my problem is i am exporting images from a table called BikeImages within

  • 0

So my problem is i am exporting images from a table called “BikeImages” within this table theres images that our under the same foreign Key BikeCode. How do i make sure the images are added together instead of seperately.

For Example

BikeCode: 123

BikeImages: IMAGE1, IMAGE2

BikeCode: 14

BikeImages IMAGE1

 <?php
            $sql1 = "SELECT BikeCode, Manufacturer, Model, SubType, Year, FrameMaterial, Description, Gender, Type, Price, Stock FROM Bike WHERE Stock > 0";
            $result1 = mysqli_query($con, $sql1);
            while(list($bikecode, $manufacturer, $model, $subtype, $year, $fmaterial, $desc, $gender, $type, $price, $stock) = mysqli_fetch_row($result1)) {            

                echo "
                <table>
                <tr><th>BikeCode:</th>
                <th>Manufacturer:</th>
                <th>Model:</th>
                <th>Subtype:</th>
                <th>Year:</th>
                </tr>
                <tr>
                <td>$bikecode</td>
                <td>$manufacturer</td>
                <td>$model</td>
                <td>$subtype</td>
                <td>$year</td>
                </tr>
                <tr>
                <th>FrameMaterial:</th>
                <th>Gender:</th>
                <th>Type:</th>
                <th>Price:</th>
                <th>Stock:</th>
                </tr>
                <tr>
                <td>$fmaterial</td>
                <td>$gender</td>
                <td>$type</td>
                <td>£$price</td>
                <td>$stock</td>
                </tr>
                <tr><th>Description:</th><td colspan=\"4\">$desc</td></tr>
                <tr><th>Bike Images:</th><td colspan=\"4\"><a href=\"$sourcepath\" title=\"$description\"><img src=\"$sourcepath\" width=\"72\" height=\"72\" /></a></td></tr>
                <tr><th>Order Now:</th><td colspan=\"4\"><a href=\"basket.php?action=add&id=$bikecode\">Add To Cart</a></td></tr>
                 </table>";
            }
      ?>

Thank you in advance for your help.

EDIT: I have to combine this code with the above code:

<?php
$sql = "SELECT SourcePath, Description, BikeCode FROM BikeImages order by bikecode";
$result = mysqli_query($con, $sql);
$previous = -1;
echo "<table>";
while(list($sourcepath, $description, $bcode) = mysqli_fetch_row($result)) {
    // if bikecode changed, append "Order now"
    if ($previous != -1 && $previous != $bcode) {
        echo "<tr><th>Order Now:</th><td colspan=\"4\"><a href=\"basket.php?action=add&id=$previous\">Add To Cart</a></td></tr>";
    }
    echo "<tr><th>Bike Images:</th><td colspan=\"4\">";
    echo "<a href=\"$sourcepath\" title=\"$description\"><img src=\"$sourcepath\" width=\"72\" height=\"72\" /></a>";
    echo "</td></tr>";
    $previous = $bcode;
}

echo "</table>\n";
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:17:09+00:00Added an answer on June 15, 2026 at 2:17 pm

    Don’t put the table tag in the loop, but outside

    <?php
        // if bikecode changed, append "Order now"
        if ($previous != -1 && $previous != $bikecode) {
            echo "<tr><th>Order Now:</th><td colspan=\"4\"><a href=\"basket.php?action=add&id=$previous\">Add To Cart</a></td></tr>";
        }
    
        echo "<tr><th>Bike Images:</th><td colspan=\"4\"><a href=\"$sourcepath\" title=\"$description\"><img src=\"$sourcepath\" width=\"72\" height=\"72\" /></a></td></tr>";
        $previous = $bikecode;
    }
    
    echo "</table>\n";
    ?>
    

    With the two selects, you have an outer loop going through bikes and an inner loop iterating over the images. An “easy” but expensive solution, could be

    <?php
    $sql1 = "SELECT BikeCode, Manufacturer, Model, SubType, Year, FrameMaterial, Description, Gender, Type, Price, Stock FROM Bike WHERE Stock > 0";
    $result1 = mysqli_query($con, $sql1) or die('Query1 failed: ' . mysqli_error($con));
    echo "<table>";
    while(list($bikecode, $manufacturer, $model, $subtype, $year, $fmaterial, $desc, $gender, $type, $price, $stock) = mysqli_fetch_row($result1)) {
        echo "<tr><th>BikeCode:</th>
              <th>Manufacturer:</th>
              <th>Model:</th>
              <th>Subtype:</th>
              <th>Year:</th>
              </tr>
              <tr>
              <td>$bikecode</td>
              <td>$manufacturer</td>
              <td>$model</td>
              <td>$subtype</td>
              <td>$year</td>
              </tr>
              <tr>
              <th>FrameMaterial:</th>
              <th>Gender:</th>
              <th>Type:</th>
              <th>Price:</th>
              <th>Stock:</th>
              </tr>
              <tr>
              <td>$fmaterial</td>
              <td>$gender</td>
              <td>$type</td>
              <td>£$price</td>
              <td>$stock</td>
              </tr>
              <tr><th>Description:</th><td colspan=\"4\">$desc</td></tr>\n";
    
        $sql = "SELECT SourcePath, Description FROM BikeImages where bikecode = '$bikecode'";
        $result = mysqli_query($con, $sql) or die('Query2 failed: ' . mysqli_error($con));
        while(list($sourcepath, $description) = mysqli_fetch_row($result)) {
              <tr><th>Bike Images:</th><td colspan=\"4\"><a href=\"$sourcepath\" title=\"$description\"><img src=\"$sourcepath\" width=\"72\" height=\"72\" /></a></td></tr>";
        }
    
        echo "<tr><th>Order Now:</th><td colspan=\"4\"><a href=\"basket.php?action=add&id=$bikecode\">Add To Cart</a></td></tr>\n";
    }
    
    echo "</table>";
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: I have a table that prints out vertical but I would like it
I'm developing a tool for exporting slides from a PowerPoint presentation to images and
I have a problem with Crystal Reports 8. When exporting a report from my
I'm having this problem with the grails liferay-plugin: localhost_liferay_portlet_WEB_INF_grails_app_views_test_view_gsp: 17: expecting anything but ''\n'';
I'm currently exploring powershell capabilities, but I have encountered a problem that I have
I'm facing an problem, exporting a what was drawn on a view to a
I am developing an image gallery application .. Its loading images from the internet..
I am currently trying to write an application that displays live video from a
I am finding I'm writing a lot of code that looks like this: <div
I am running a problem with exporting a Google Docs (spreasheet) to xls file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.