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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:45:49+00:00 2026-06-03T23:45:49+00:00

I have 2 mysql queries retrieved from my php class 2 different methods and

  • 0

I have 2 mysql queries retrieved from my php class 2 different methods and they look as it follows

 SELECT
domains.id,  domains.name, domains.meta_title,
domains.meta_keywords,  domains.meta_description,
produkt_modul.keywords, produkt_modul.program_id,produkt_modul.title, produkt_modul.items, produkt_modul.search_type
 FROM domains
 JOIN produkt_modul ON domains.id = produkt_modul.domains_id WHERE domains.name='$domain_name' ORDER BY position

is fetching the rows for my product modules
and the second one

SELECT
domains.id, text_module.position, text_module.title, text_module.text
FROM    domains
JOIN    text_module
ON  domains.id = text_module.domains_id
WHERE   domains.name='$domain_name' AND active= 1 ORDER BY position

should give me the rows of the text modules.

When I generate the html output of the rows in my view I would like to order theme after the positions value.

what should look for example something like:

text_modul pos1
prod_modul pos2
prod_modul pos3
text_modul pos4

the actual view of the rows looks

text_modul1
text_modul4
prod_modul2
prod_modul3

How can I fetch the rows in such a way to have theme in the correct order.

  • 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-03T23:45:51+00:00Added an answer on June 3, 2026 at 11:45 pm

    Here’s how to do it in PHP. Note that this code assumes position is unique across both produkt_module and text_module results.

    $allrows = array();
    $res = mysql_query(/* your first query on produkt_module */);
    while ($row = mysql_fetch_assoc($res) {
        $row['type'] = 'p';
        $allrows[$row['position']] = $row;
    }
    
    $res = mysql_query(/* your second query on text_module */);
    while ($row = mysql_fetch_assoc($res) {
        $row['type'] = 't';
        $allrows[$row['position']] = $row;
    }
    
    ksort($allrows);  // sort all rows by position
    
    foreach ($allrows as $pos => $row) {
        if ($row['type'] == 'p') {
            /* display a produkt_module row, i.e $row['title'], etc. */
        } elseif ($row['type'] == 't') {
            /* display a text_module row */
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two mysql queries: $sql = SELECT * FROM content WHERE threadName LIKE
I have building MYSQL queries with backticks. For example, SELECT `title` FROM `table` WHERE
I have to run some mysql update queries and they take quite a long
I have two queries to get related tags from a mysql database, one works,
I have a mysql query that uses union to join multiple queries into one
I have a Python script that queries a MySQL database every 5 seconds, gathering
I have a search form with min and max fields. It queries a MySQL
I have to combine these two mySQL queries into one. I duplicated a solution
I have a website that calculates a users involvement/activity using multiple MySQL queries. For
Should numbers from user input be quoted in MySQL queries to help avoid SQL

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.