PHP error when sending data to screen

Scott Johnston
Scott Johnston used Ask the Experts™
on
I'd like to run a PHP script to return the values in a database, I can do it with no problem but when I add the "Order by" into my script, I am getting an error.  This script worked great until I added the "order by".
Here is my simple script...Please advise:  
----------------------------------------------------------------------------------------------------------
Here is when I connect to MYSQL (Left that part out)
---------------------------------------------------------------------------------------------------------

$result = mysqli_query($con,"SELECT ItemNumber, StartingDate, EndingDate, SalePrice FROM biomas.ITProductSale order by ItemNumber");

 echo "<table border='1'>
 <tr>
 <th>Item Number</th>
 <th>Starting Date</th>
 <th>Ending Date</th>
 <th>Sale Price</th>
 </tr>";

 while($row = mysqli_fetch_array($result))
   {I
   echo "<tr>";
   echo "<td>" . $row['ItemNumber'] . "</td>";
   echo "<td>" . $row['StartingDate'] . "</td>";
   echo "<td>" . $row['EndingDate'] . "</td>";
   echo "<td>" . $row['SalePrice'] . "</th>";
   echo "</tr>";
   }
 echo "</table>";

 mysqli_close($con);
 ?>
------------------------------------------------------------------------------
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
What is the error you're getting?
Expert of the Year 2014
Top Expert 2014

Commented:
What is biomas
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
I have never seen that cause a problem.  What is the error message?
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

Scott JohnstonIT Technician

Author

Commented:
Has to do with the line "echo "<tr>";"
Parse Error: syntax Error, unexpected T_ECHO in (FIle name)C:\Inetpub\xxxxxxxxxx\xxxxxxxxxxxxxxxx on line 21"

I do not see my error, or because I am sorting the data it will not print out the same...?
Scott JohnstonIT Technician

Author

Commented:
BIOMAS name of our MYSQL database
Expert of the Year 2014
Top Expert 2014
Commented:
Is that an exact copy of your code?

while($row = mysqli_fetch_array($result))
   {I // what is the l doing here?
    echo "<tr>";


Also
echo "<td>" . $row['SalePrice'] . "</th>";
You are opening a TD tag and closing a TH tag - no biggie but should be corrected.
Scott JohnstonIT Technician

Author

Commented:
I put the Select statement in MYSQL and it works perfectly....
Scott JohnstonIT Technician

Author

Commented:
Hmmm, missed that...Fixed everything>!!!!!!
Scott JohnstonIT Technician

Author

Commented:
Sometime it help to have more than one person looking at coding even as simple as this code...Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial