We help IT Professionals succeed at work.

PHP error when sending data to screen

Scott Johnston
on
315 Views
Last Modified: 2014-08-26
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

gr8gonzoConsultant
CERTIFIED EXPERT

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

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

Commented:
I have never seen that cause a problem.  What is the error message?
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
CERTIFIED EXPERT
Expert of the Year 2014
Top Expert 2014
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
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
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.