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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:07:55+00:00 2026-05-25T19:07:55+00:00

I have created my first join query to display some WordPress content on a

  • 0

I have created my first join query to display some WordPress content on a home page of a website, so far so good, but there are two columns in the joined tables with name “ID”. I lost ability to use one of the column names as a variable later on (in a link).

“echo $row[‘ID’]” does not display the value anymore (used to, before tables were joined).

“echo $row[‘wp_posts.ID’]” does not seem to do anything either.

What should I do?

$query = "SELECT wp_posts.ID, wp_posts.post_title, wp_posts.post_excerpt, wp_posts.post_author, wp_users.ID, wp_users.display_name FROM wp_posts, wp_users  WHERE wp_posts.post_status = 'publish' AND wp_users.ID = wp_posts.post_author ORDER BY wp_posts.post_date DESC LIMIT 2";
$result = mysql_query($query) or die(mysql_error()); 
?>

<?php 
      while ($row = mysql_fetch_array($result)){ 
          echo "<h2>" . $row['post_title']; ?></h2>
          <p class="post_author">
          by <?php echo $row['display_name'];?></p>
          <?php $text = explode("***",wordwrap(strip_tags($row['post_excerpt']),150,"***",true));
                echo " ".$text[0]." ";
        ?>... <a href="http://www.pihl.ca/kelownalawyers/?p=<?php echo $row['ID'];?>"> READ MORE</a><p />

<?php 

}  
?>
  • 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-25T19:07:56+00:00Added an answer on May 25, 2026 at 7:07 pm
    SELECT wp_posts.ID AS wpp_id, wp_users.ID AS wpu_id
    

    and then reference with with $row[‘wpp_id’] and $row[‘wpu_id’] in your loop

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

Sidebar

Related Questions

Let me first describe my goal: I have created an object with 3 properties:
I have created a file argument.pl which takes several arguments first of which should
I have a folder with these files: alongfilename1.txt <--- created first alongfilename3.txt <--- created
I am trying to write my first WCF project. I have created a project
I'm new to NHibernate and trying to create my first mapping. I have created
I have a big project that was first created in Borland C++ 6. We're
I have two query like this; SELECT j.ID, j.Pkey, j.SUMMARY, j.CREATED, j.RESOLUTIONDATE ,j2.SUMMARY, j2.CREATED,
I want to display a FULL JOIN of two tables, but using an intermediary
i have created view , in short it display last 5 news title and
So far in the website I have only found stored procedures to list all

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.