PHP error when sending data to screen

Posted on 2014-08-26
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'>
 <th>Item Number</th>
 <th>Starting Date</th>
 <th>Ending Date</th>
 <th>Sale Price</th>

 while($row = mysqli_fetch_array($result))
   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>";

Question by:Scott Johnston
    LVL 34

    Expert Comment

    What is the error you're getting?
    LVL 58

    Expert Comment

    What is biomas
    LVL 82

    Expert Comment

    by:Dave Baldwin
    I have never seen that cause a problem.  What is the error message?

    Author Comment

    by:Scott Johnston
    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...?

    Author Comment

    by:Scott Johnston
    BIOMAS name of our MYSQL database
    LVL 58

    Accepted Solution

    Is that an exact copy of your code?

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

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

    Author Comment

    by:Scott Johnston
    I put the Select statement in MYSQL and it works perfectly....

    Author Comment

    by:Scott Johnston
    Hmmm, missed that...Fixed everything>!!!!!!

    Author Closing Comment

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to dynamically set the form action using jQuery.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now