Order by and row number

hi,Please i have been trying to include a row number that increases for each new row, and also make the list show by arranging the result of the query by the shop name but hitting brick wall:confused:.

this is the code

<tr>
    <th>ROW NO</th>
    <th>SHOP NAME</th>
    <th>PRODUCT NAME</th>
    <th>PRODUCT SIZE</th>
    <th>PRODUCT COLOUR</th>
    <th>PRODUCT QUANTITY</th>
    <th>PRICE</th>
    <th>TOTAL</th>
    <th></th>
    </tr>
    <?php
    // Get DB results and loop, outputting table rows with counter
    $pplresult = mysql_query("SELECT * FROM repplac WHERE Uname = '{$_SESSION['username']}'") or die(mysql_error());
   for ($i = 0; $row = mysql_fetch_assoc($pplresult); $i++) {
    echo "
    <tr>
 <td>""</td>
    <td>".htmlspecialchars($row['Sname'])."</td>
    <td>".htmlspecialchars($row['Pname'])."</td>
    <td>".htmlspecialchars($row['Psize'])."</td>
    <td>".htmlspecialchars($row['Pcolour'])."</td>
    <td>
    <input type='text' name='item[$i][Pquantity]' id='Pquantity' value='".htmlspecialchars($row['Pquantity'])."' />
    <input type='hidden' name='item[$i][Pidno]' id='Pidno' value='".htmlspecialchars($row['Pidno'])."' />
    </td>
    <td>
    <input type='text' name='item[$i][Price]' id='Pquantity' value='".htmlspecialchars($row['Price'])."' readonly>
    </td>
    <td>".htmlspecialchars($row['Tprice'])."</td>
    <td><a href='deleteproduct.php?del=".htmlspecialchars($row['Pidno'])."'>delete</a></td>
    </tr>";
    }

any suggestions or guide will be appreciated

applying a row number can be done very easily with php

sorting by shop name requires an ORDER BY clause in your SELECT statement

i have sorted the “order by”,statement, but applying the row numbers is not yielding, closest articles or forums am seeing re using sql functions like “@row := @row + 1” and its not working.

i have sorted it thanks for the guidance