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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:46:42+00:00 2026-05-22T01:46:42+00:00

Hello I have a question that could seem complicated. But I will try to

  • 0

Hello I have a question that could seem complicated. But I will try to explain it as better as I can. This is a problem of logic.
I have a database table. This database table (lets call it Table A) contains some strings.
Strings are composed by these rows:

ID (auto increment)
Text
Date 
Time
Type
IDAccount.

Now some of these strings are equal. I need to SELECT all the strings that are equal and have them in one result.

So the logic of the code will be:

SELECT * from Table A WHERE mySQL find stringS with same Text, Date and Time. 

Then “echo” for only ONE TIME(so not for any string, since they are perfectly equal): Text Date Time. (this will be an HTML DIV)

Then in these strings we have some other rows that have DIFFERENT values.

Type
IDAccount.

The PHP will have to show for these rows(Type, IDAccount) all the different values found for the EQUAL strings above.

So the final DIV would be:

Text (one time)
Date (one time)
Time (one time)
Type (every different value that is found will be shown)
IDAccount (every different value that is found will be shown).

I know this is something difficult to understand. I hope someone got my point.
The most important thing is “how to say to mySQL to SELECT all the strings that are equale for rows Text , Date and Time and show 1 result in the final DIV, and then how to show the not equal values for all those strings (Type, IDAccount) and show all of them in the same final DIV”.

Any help would be very appreciated!!

Lets play with it =D

  • 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-05-22T01:46:43+00:00Added an answer on May 22, 2026 at 1:46 am

    I think the best way to do this would be in the PHP code, rather than in SQL.

    You can achieve this by simply creating an associative array in PHP, using the “text” field as a key, that contains the data you want – and populating it as you pull information from the database.

    An example:

    SQL:
    SELECT * FROM myTable

    PHP Code:

    <?php
    
    // Connect to MySQL database
    $result = mysql_query($sql_query_noted_above);
    $stringsInfo = array();
    while ($row = mysql_fetch_assoc($result))
    {
        if (!isset($stringsInfo[$row['text']]))
        {
            $stringsInfo[$row['text']] = array('types' => array(), 'idAccounts' => array());
        }
    
        $stringsInfo[$row['text']]['types'][] = $row['type'];
        $stringsInfo[$row['text']]['idAccounts'][] = $row['idAccount'];
    }
    
    ?>
    

    This will give you an array as follows:

    'myTextString' => 'types' => 'type1', 'type2', 'type3'
                      'idAccounts' => 'account1', 'account2'
    
    'anotherTextString' => 'types' => 'type2', 'type4'
                           'idAccounts' => 'account2', 'account3'
    

    and so on.

    I hope that’s helpful.

    EDIT: Poster asked for help with display.

    <?php
    
    foreach ($stringsInfo as $string => $info)
    {
        echo $string . '<br />';
        echo 'Types: ' . implode(', ', $info['types']); // This will echo each type separated by a comma
        echo '<br />';
        echo 'ID Accounts: ' . implode(', ', $info['idAccounts']);
    }
    

    /* Alternatively, you can loop each array contained in $info if you need more control */

    foreach ($stringsInfo as $string => $info)
    {
        echo $string . '<br />';
        echo 'Types: ';
        foreach ($info['types'] as $type)
        {
            echo $type . ' - ';
        }
        echo '<br />';
        echo 'ID Accounts: '
        foreach ($info['idAccounts'] as $idAccount)
        {
            echo $idAccount . ' - ';
        }
    }
    

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

Sidebar

Related Questions

hello I have a small question in objective-C memory management. I know that if
Hello this is may first question and I have found so far the following
i have this: <div id=parent style=overflow:auto> ... <div id=test>Hello</div> ... </div> My question is:
Hello good people of stackoverflow, this is a conceptual question and could possibly belong
This might seem like a very simple question, but I am struggling with it.
Hello all i have a quick question Is there a way i could make
Hello guys and sorry for such a long question, but... I have a C#
Hello i have a question on picking random entries from a database. I have
Hello is have a question for a school assignment i need to : Read
Hello guys sorry if the question looks stupid to you. i have 3 tables

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.