In and around Union Square and Nob Hill, you’ll find about a zillion different hotels. As a rule, those closest to the top of the Hill or to Union Square proper are the most expensive.
For a one- or two-block walk, you get more personality and genuine San Francisco [1] experience for less money and less prestige. There’s little cheap in these areas; hostels run down in the direction of the Tenderloin, where safety becomes an issue after dark.
Links:
[1] http://www.moon.com/destinations/california/san-francisco-and-the-bay-area