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 7829675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:52:36+00:00 2026-06-02T10:52:36+00:00

I’m now hopeless about this problem and that’s why I’m here. I’m kind of

  • 0

I’m now hopeless about this problem and that’s why I’m here. I’m kind of a starter in PHP and mysql programming. I searched for a solution on the web but I wasn’t succeeded. I’m working on a project what is a car repairing administration system. This is a part of it that I need.

I have two tables:

repairs (j_id /this is the primary key/, rendszam, javitas, megjegyzes, datum) 
and 
pictures (kep_id /this is the primary key/, j_id /it's from repairs j_id/, kepnev)

I need to display a result in a table, where I can see that which of the repairs have a picture in the pictures table, but without redundancy, so I don’t want multiple repair rows that are similar to eachother, but one repair row with multiple picture columns after it.

What I have done already:

<?php
$sql = "SELECT $tbl_name2.j_id, $tbl_name2.rendszam, $tbl_name2.javitas, $tbl_name2.megjegyzes, $tbl_name2.datum, $tbl_name3.kepnev FROM $tbl_name2, $tbl_name3 WHERE $tbl_name2.j_id=$tbl_name3.j_id";

$result = mysql_query($sql) or die(mysql_error());

while ($row = mysql_fetch_array($result)) {
    echo "<tr><td>" . $row[$i] . "</td>";
    echo "<td>" . $row[$i + 1] . "</td>";
    echo "<td>" . $row[$i + 2] . "</td>";
    echo "<td>" . $row[$i + 3] . "</td>";
    echo "<td>" . $row[$i + 4] . "</td>";
    echo "<td>" . $row[$i + 5] . "</td>";
}
?>

This one displays information like this:

repair id | picture

1    |    fdgdfg.jpg
1    |    fgdfg.jpg
1    |    fghh.jpg
25   |    dfg.jpg
25   |    jkjk.jpg

But I don’t want to have multiple repair rows but one repair row with multiple pictures after it.

I tried this:

$sql2="SELECT DISTINCT $tbl_name2.j_id, $tbl_name3.kepnev FROM $tbl_name2, $tbl_name3 WHERE $tbl_name2.j_id=$tbl_name3.j_id";

$result2=mysql_query($sql2) or die(mysql_error());

$sql="SELECT $tbl_name2.j_id, $tbl_name2.rendszam, $tbl_name2.javitas, $tbl_name2.megjegyzes, $tbl_name2.datum, $tbl_name3.kepnev FROM $tbl_name2, $tbl_name3 WHERE $tbl_name2.j_id=$tbl_name3.j_id GROUP BY j_id;

$result=mysql_query($sql) or die(mysql_error());

while($row=mysql_fetch_array($result))
{
echo "<tr><td>".$row[$i]."</td>";
echo "<td>".$row[$i+1]."</td>";
echo "<td>".$row[$i+2]."</td>";
echo "<td>".$row[$i+3]."</td>";
echo "<td>".$row[$i+4]."</td>";
echo "<td>".$row[$i+5]."</td>";
while($sor=mysql_fetch_array($result2))
    {
        if($sor['j_id']==$row[$i]){
        echo "<td><a href=kepek/".$sor['kepnev']." target=_blank>".$sor['kepnev']."</a></td>";
        }
    }

}

The sql statement differs in the group by in $sql, but this one displays the results like this:

 repair id | picture

    1    |    fdgdfg.jpg | fgdfg.jpg | fghh.jpg
    25   |        

So it’s just not continuing after the first repair id, not showing the repair pictures for repair id 25.

I don’t know, how can I get it right. I need a table which displays information like this:

repair id | picture

   1    |    fdgdfg.jpg | fgdfg.jpg | fghh.jpg
   25   |    dfg.jpg | jkjk.jpg

Could you help me out in this?

  • 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-02T10:52:37+00:00Added an answer on June 2, 2026 at 10:52 am

    This sounds fairly straightforward, looks like you’re off to a good start.

    I’ve done something similar in the past, and I just used a variable to keep track of the current ID being displayed and the previously displayed ID. Here’s a quick code sample to outline what I mean by that.

    while($row=mysql_fetch_array($result))
    {
        $currentID=$row[$i];
        if ($currentID != $lastID) { 
            echo "</tr><tr><td>".$row[$i]."</td>"; 
        } else {
            echo "<td>".$row[$i]."</td>";   
        }
        $lastID=$row[$i];
    }
    

    So, the idea is to keep track of what the last ID was. In the next row, if the ID is the same, just output <td>”variable goes here”</td> to keep it on the same column. If the ID changed, end the row and create a new row using </tr><tr>”. Feel free to comment if you need more help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've tracked down a weird MySQL problem to the two different ways I was
I know there's a lot of other questions out there that deal with this
I'm trying to create an if statement in PHP that prevents a single post
I have a jquery bug and I've been looking for hours now, I can't
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.