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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:25:15+00:00 2026-05-28T21:25:15+00:00

The problem I have is when I echo or print the following variables, the

  • 0

The problem I have is when I echo or print the following variables, the data I receive is that of the last business listed in my table only.

At present no matter the listing I click I get the same set of data for the last business returned.

As you can see in the below code I am passing the business_name from the clicked listing to be used in my query to find the relevant business profile information.

$business_name = mysql_real_escape_string($_GET['business_name']);

$query = "SELECT
business_id,
category,
years_recommended,
profile_size,
business_name,
established,
employees,
service,
strengths,
ideal_for,
reassurance

FROM
business_data

WHERE
business_name = '$business_name'

AND
profile_size = 'A'

OR
profile_size = 'B'

OR
profile_size = 'C'

OR
profile_size = 'D'

OR
profile_size = 'E'";

$result = mysql_query($query, $dbc)
or die (mysql_error($dbc));

while($row = mysql_fetch_array($result)) {

$business_id = $row["business_id"];
$profile_size = $row["profile_size"];
$category = $row["category"];
$years = $row["years_recommended"];
$established = $row["established"];
$employees = $row["employees"];
$service = $row["service"];
$strengths = $row["strengths"];
$ideal_for = $row["ideal_for"];
$reassurance = $row["reassurance"];
}

echo...

If you need more information please let me know.

Is there anything wrong with my code?

Many thanks in advance.

  • 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-28T21:25:16+00:00Added an answer on May 28, 2026 at 9:25 pm

    Your echo call is outside the fetch loop, so you’ll only see the last result even though the others were returned.

    while($row = mysql_fetch_array($result)) {
    
      $business_id = $row["business_id"];
      $profile_size = $row["profile_size"];
      $category = $row["category"];
      $years = $row["years_recommended"];
      $established = $row["established"];
      $employees = $row["employees"];
      $service = $row["service"];
      $strengths = $row["strengths"];
      $ideal_for = $row["ideal_for"];
      $reassurance = $row["reassurance"];
    
      // Echo **inside** the loop
      echo...
    }
    

    If you wish, you can store all the results in a large array, which can then be used anywhere subsequently in your script, as many times as needed:

    // Array for all results
    $results = array();
    while($row = mysql_fetch_array($result)) {
      // Append each row fetched onto the big array
      $results[] = $row;
    }
    // Now use it as needed:
    foreach ($results as $r) {
      echo $r['profile_size'];
      print_r($r);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code for an echo client that sends data to an
I have a problem with the following awk syntax echo param1 param2 param3 =
I have a problem want to know answer, Why the following code will print
I have an extremely simple JSON object that looks like the following: var data
Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem I have timestamped data, which I need to search based on the timestamp
Problem: We have a web app that calls some web services asynchronously (from the
Problem: I have a python script that I have running as a service. It's
Problem : I have a hand held device that scans those graphic color barcodes
Problem I have a custom tab control using Chrome-shaped tabs that binds to a

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.