Displaying the same record multiple times

I can't seem to figure this out.  I am trying to diplay the reviews of a company from the db.  The company has 3 reviews, but right now only one review displays twice.  Can anyone help me with this?

<?php

$conn = mysql_connect("127.0.0.1", "", "");
mysql_select_db("providers", $conn);

$SQLstr = mysql_query("SELECT tblReviews.strCompanyname, tblReviews.strReportdate, tblReviews.strServicecat, tblReviews.strMonthstart, tblReviews.strDaystart, tblReviews.strYearstart, tblReviews.strDayend, tblReviews.strMonthend, tblReviews.strYearend, tblReviews.strWorkperform, tblReviews.strComments, tblReviews.strSatisfied, tblReviews.strPricereas, tblReviews.strFinishedontime, tblReviews.strReceiveguar, tblReviews.strTreatedfair, tblReviews.strShowontime, tblReviews.strCallsreturned, tblReviews.strCleanup, tblReviews.strOverall, tblReviews.strHireagain, tblReviews.strQuote, tblReviews.strActualprice, tblAdspace.strProviderservice, tblReviews.reviewID, tblAdspace.strCompanyname, tblReviews.strCustomer FROM tblReviews INNER JOIN tblAdspace ON tblReviews.strCompanyname = tblAdspace.strCompanyname WHERE tblReviews.strCompanyname = '" . $_GET['Company'] . "' ORDER BY tblReviews.strReportdate DESC")
or die(mysql_error());

while ($row = mysql_fetch_array($SQLstr)) {
$strCompanyname = $row['strCompanyname'];
$strReportdate = $row['strReportdate'];
$strServicecat = $row['strServicecat'];
$strWorkperform = $row['strWorkperform'];
$strComments = $row['strComments'];
$strMonthstart = $row['strMonthstart'];
$strDaystart = $row['strDaystart'];
$strYearstart = $row['strYearstart'];
$strMonthend = $row['strMonthend'];
$strDayend = $row['strDayend'];
$strYearend = $row['strYearend'];
$strSatisfied = $row['strSatisfied'];
$strPricereas = $row['strPricereas'];
$strFinishedontime = $row['strFinishedontime'];
$strReceiveguar = $row['strReceiveguar'];
$strTreatedfair = $row['strTreatedfair'];
$strShowontime = $row['strShowontime'];
$strCallsreturned = $row['strCallsreturned'];
$strCleanup = $row['strCleanup'];
$strOverall = $row['strOverall'];
$strHireagain = $row['strHireagain'];
$strQuote = $row['strQuote'];
$strActualprice = $row['strActualprice'];
$strProviderservice = $row['strProviderservice'];
$reviewID = $row['reviewID'];
}
?>
LVL 1
pingeyegAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

glcumminsCommented:
What happens in your code after the "while($row..." statement? How are you displaying the data? Specifically, you need to make sure that the display portion appears in the while() loop. If you are waiting to display the data until after the while loop is complete, your variables are getting overwritten with the last record found, and only that record will be displayed.
0
pingeyegAuthor Commented:
This is the beginning of the code, just to hopefully make your question clear.

$SQLstr = mysql_query("SELECT tblReviews.strCompanyname, tblReviews.strReportdate, tblReviews.strServicecat, tblReviews.strMonthstart, tblReviews.strDaystart, tblReviews.strYearstart, tblReviews.strDayend, tblReviews.strMonthend, tblReviews.strYearend, tblReviews.strWorkperform, tblReviews.strComments, tblReviews.strSatisfied, tblReviews.strPricereas, tblReviews.strFinishedontime, tblReviews.strReceiveguar, tblReviews.strTreatedfair, tblReviews.strShowontime, tblReviews.strCallsreturned, tblReviews.strCleanup, tblReviews.strOverall, tblReviews.strHireagain, tblReviews.strQuote, tblReviews.strActualprice, tblAdspace.strProviderservice, tblReviews.reviewID, tblAdspace.strCompanyname, tblReviews.strCustomer FROM tblReviews INNER JOIN tblAdspace ON tblReviews.strCompanyname = tblAdspace.strCompanyname WHERE tblReviews.strCompanyname = '" . $_GET['Company'] . "' ORDER BY tblReviews.strReportdate DESC")
or die(mysql_error());

while ($row = mysql_fetch_array($SQLstr)) {
$strCompanyname = $row['strCompanyname'];
$strReportdate = $row['strReportdate'];
$strServicecat = $row['strServicecat'];
$strWorkperform = $row['strWorkperform'];
$strComments = $row['strComments'];
$strMonthstart = $row['strMonthstart'];
$strDaystart = $row['strDaystart'];
$strYearstart = $row['strYearstart'];
$strMonthend = $row['strMonthend'];
$strDayend = $row['strDayend'];
$strYearend = $row['strYearend'];
$strSatisfied = $row['strSatisfied'];
$strPricereas = $row['strPricereas'];
$strFinishedontime = $row['strFinishedontime'];
$strReceiveguar = $row['strReceiveguar'];
$strTreatedfair = $row['strTreatedfair'];
$strShowontime = $row['strShowontime'];
$strCallsreturned = $row['strCallsreturned'];
$strCleanup = $row['strCleanup'];
$strOverall = $row['strOverall'];
$strHireagain = $row['strHireagain'];
$strQuote = $row['strQuote'];
$strActualprice = $row['strActualprice'];
$strProviderservice = $row['strProviderservice'];
$reviewID = $row['reviewID'];
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Ask2bsure.com - (Admin Section) Edit Provider</title>
<link style="text/css" href="/css/style.css" rel="stylesheet">
</head>
<body>
<table align="center" id="admin">
<tr><td align="center" colspan="2">
<img src="/images/sublogo_2.png"><br />
<span style="font-size: 12px; color: #0000FF">(Admin Section)</span>
</td></tr>
<tr><td valign="top">
<div id="navlist">
<a href="/admin/">Home</a>
<a href="/admin/add_provider.php">Add Provider</a>
<a href="/admin/list_providers.php?list=list">Delete / Edit Provider</a>
<a href="/admin/list_providers.php?review=review">Toggle / Edit Reviews</a>
<a href="/index.php">Back To Website</a>
</div>
</td><td width="625">
<table id="main_admin" align="center" border="0">
<tr><td>
<?php
$rows = 0;
while ($rows <= 1) {
?>
<table id="review_admin" border="0" style="margin-bottom: 30px"><tr>
<form action="/admin/update_review.php" method="post">
<td colspan="4" id="review_header" align="center">
<input type="hidden" value="<?= $strCompanyname ?>" name="strCompanyname">
<input type="hidden" value="<?= $reviewID ?>" name="reviewID">
<?= $strCompanyname ?>
0
mukhtar2tCommented:
I think your problem is in the query inner join it self , try
echo $SQLstr;
and paste the result to mysql
0
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

pingeyegAuthor Commented:
SELECT tblReviews.strCompanyname, tblReviews.strReportdate, tblReviews.strServicecat, tblReviews.strMonthstart, tblReviews.strDaystart, tblReviews.strYearstart, tblReviews.strDayend, tblReviews.strMonthend, tblReviews.strYearend, tblReviews.strWorkperform, tblReviews.strComments, tblReviews.strSatisfied, tblReviews.strPricereas, tblReviews.strFinishedontime, tblReviews.strReceiveguar, tblReviews.strTreatedfair, tblReviews.strShowontime, tblReviews.strCallsreturned, tblReviews.strCleanup, tblReviews.strOverall, tblReviews.strHireagain, tblReviews.strQuote, tblReviews.strActualprice, tblAdspace.strProviderservice, tblReviews.reviewID, tblAdspace.strCompanyname, tblReviews.strCustomer FROM tblReviews INNER JOIN tblAdspace ON tblReviews.strCompanyname = tblAdspace.strCompanyname WHERE tblReviews.strCompanyname = 'Plumbing When You Need It' ORDER BY tblReviews.strReportdate DESC
0
glcumminsCommented:
Okay, let me reiterate what I said in my first post. In your while loop, you are copying the MySQL results into the variables three times. Then the loop ends, with only the last set of MySQL results in the variables.

Then, you are beginning your display portion. This only displays the last record, because that is all that the variables contain.

You need to move your display section (the HTML code) into the while() loop, so that the current record set is displayed at the same time as it is fetched.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pingeyegAuthor Commented:
So do you mean to move the while loop of variables right after the while loop that makes the rows like this?

<?php
$rows = 0;
while ($rows <= 1) {

      while ($row = mysql_fetch_array($SQLstr)) {
$strCompanyname = $row['strCompanyname'];
$strReportdate = $row['strReportdate'];
$strServicecat = $row['strServicecat'];
$strWorkperform = $row['strWorkperform'];
$strComments = $row['strComments'];
$strMonthstart = $row['strMonthstart'];
$strDaystart = $row['strDaystart'];
$strYearstart = $row['strYearstart'];
$strMonthend = $row['strMonthend'];
$strDayend = $row['strDayend'];
$strYearend = $row['strYearend'];
$strSatisfied = $row['strSatisfied'];
$strPricereas = $row['strPricereas'];
$strFinishedontime = $row['strFinishedontime'];
$strReceiveguar = $row['strReceiveguar'];
$strTreatedfair = $row['strTreatedfair'];
$strShowontime = $row['strShowontime'];
$strCallsreturned = $row['strCallsreturned'];
$strCleanup = $row['strCleanup'];
$strOverall = $row['strOverall'];
$strHireagain = $row['strHireagain'];
$strQuote = $row['strQuote'];
$strActualprice = $row['strActualprice'];
$strProviderservice = $row['strProviderservice'];
$reviewID = $row['reviewID'];
}
?>
0
glcumminsCommented:
What are you trying to accomplish with this code?

   $rows = 0;
   while ($rows <= 1)

 Your 'while($row = mysql_fetch_array(...))' loop will already give you the correct number of iterations: If you received three records from the database, three records will be displayed.
0
pingeyegAuthor Commented:
I thought I needed that to display multiple rows.  Well, now that I took that line out I only show one table of records on the page instead of 3 tables on the page.
0
pingeyegAuthor Commented:
Nevermind, I just realized that I closed the while statement too early.  After I moved the closed bracket  to the bottom of the page all 3 records showed up correctly.  Thanks!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.