The US lost 23,000 jobs in July, raising concerns about the economy ahead of the November midterm elections.