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

  • Home
  • SEARCH
  • 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 976929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:49:26+00:00 2026-05-16T03:49:26+00:00

My query look like this at the moment: $result = mysql_query(SELECT * FROM promo

  • 0

My query look like this at the moment:

  $result  = mysql_query("SELECT * FROM promo JOIN items ON promo.id = items.promo_id WHERE promo.id='$promo_id'") or die('Error : ' . mysql_error()); 
  while($row = mysql_fetch_array($result))
  {
  echo "<p>".$row['title']."</p>";
  echo "<p>".$row['description']."</p>";
  echo "<p>".$row['filename']."</p>";
  }

I’d like to end up with the following:

  • Title of Promo 1

  • This is Promo 1 Description, isn’t it great?!

  • filename_1.jpg

  • filename_2.jpg and however many files are linked to this promo listed…

However, based on the query above I get:

  • This is Promo 1 Description, isn’t it great?!

  • filename_1.jpg

  • This is Promo 1 Description, isn’t it great?!

  • filename_2.jpg

So it repeats (I can sort of see why) and doesn’t pull in the ‘title’ of the promo at all! Can anyone recommend whether the problem is with my JOIN or my PHP? Many thanks for your help 🙂

  • 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-16T03:49:27+00:00Added an answer on May 16, 2026 at 3:49 am

    Probably description and filename appears because these names exists on only one of the tables but title is on both tables.

    If you use the query:

    SELECT 
         * 
    FROM 
         promo JOIN items ON promo.id = items.promo_id WHERE promo.id='$promo_id'"
    

    The names of the fields are need to be in the way table.field . it’s very in useful to expecify the names of the fields you need to get to help you and to fetch only the data you need and not all the table. This makes the method faster to retrive the rows and prevent problems with the names.

    Also you can specify the name of a column wit the sentence “AS”
    Example:

    SELECT 
       promo.title AS title,
       promo.description AS description,
       items.filename AS filename
    FROM 
        promo JOIN items ON promo.id = items.promo_id WHERE promo.id='$promo_id'"
    

    And you get a table like (i setted imaginary data on it):

    title | description | filename
    -------------------------------
    title1|description1 | filename1
    title1|description1 | filename2
    title2|description2 | filename3
    

    Tips:

    • If you got more than one item per promo all data is repeated on each row.

      • You need to queries to display all items per promo without repeat the promo data,make more complex query or add some code.
    • If you don’t have any item for the promo the promo is does not appears into the list.

      • You need to use list al promos and by each list its own items to show the promos without items or use an OUTER JOIN query.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.