im pretty new to php but maybe this can get you the last entry.
i might be totally off here but anyway if you cant find anything else you can mess with this code .
...
$query = "SELECT FROM carts
WHERE numBought = '".$prodID."')";
$result = mysql_query($query);
$num_results = mysql_num_rows($result); / sometimes this gives this: "Supplied argument is not a valid MySQL result resource" ( dont know why, hope not for you) */
$row = mysql_fetch_array($result);
echo "This should be your last entry: ";
echo htmlspecialchars (stripslashes($row["prodID"]));
echo "<br>Quantity: ";
echo htmlspecialchars (stripslashes($row["numBought"]));
...