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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:44:25+00:00 2026-06-16T20:44:25+00:00

I have searched for my question but none seems to answer my particular need.

  • 0

I have searched for my question but none seems to answer my particular need. It is a simple table join but every thing i have tried has failed. maybe you can help. NOTES: all rows have post_id in POSTS but not all post_ids are related in CALENDAR, ie not all posts have calendar entries. And I am using MYSQL in PHP, not MYSQLi.

POST_CAT- post_id, cat_id
POSTS- post_id, title, description
CALENDAR- post_id, on_date, to_date

currently i found the relevant post_ids through a many to many selection then used a series of for loops to output from a single table. this works. but i need to include the calendar entries for relevant post_id in one array:

mysql_connect("localhost", "root", "root") or die(mysql_error());
mysql_select_db("adamsmap_db") or die(mysql_error());

if (isset($_POST['activities'])) {

$post_id = mysql_query("SELECT post_id FROM post_cat WHERE cat_id = '1'");
    while ($row = mysql_fetch_array($post_id, MYSQL_NUM)) {

    for ($i=0;$i < count($row); $i++) {

$output = mysql_query("SELECT user_id, title, description FROM posts WHERE post_id='$row[$i]'");
    while ($rowoutput = mysql_fetch_array($output, MYSQL_NUM)) {

    for($i=0;$i < count($rowoutput);$i++) {

echo $rowoutput[$i]."&nbsp";

}

echo"<br /> <br />";

}}}}    
  • 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-16T20:44:26+00:00Added an answer on June 16, 2026 at 8:44 pm

    This query will replicate the business logic you’ve coded and the calendar info:

    SELECT 
        zpc.ost_id, p.user_id, p.title, p.description, c.*
    FROM Z_post_cat zpc
    INNER JOIN posts p ON zpc.post_id = p.post_id 
    INNER JOIN calendar c ON c.post_id = = p.post_id
    WHERE zpc.cat_id = '1'
    

    If you wish to include categories which do not have posts, use LEFT JOIN instead of INNER JOIN.

    Also, it’s recommended that you move to PDO or Mysqli instead of mysql due to security concerns.

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

Sidebar

Related Questions

I have searched for an answer but couldn't find it anywhere. My question is
I have searched this server for the answer to this question but I haven't
I have already searched from this question in SO. But none of the answers
I searched for a similar question but found none so far. I have a
I have searched and found another with quite close question but the result was
I realize this is a basic question but I have searched online, been to
I have searched stackoverflow for a question like mine but most of the questions
I have what I know is a simple question, but after many searches in
I have searched for hours for the answer to my question and have found
I have searched and found many questions similar to mine but none of the

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.