First, let's remember why the integers and rationals are PIDS.

Integers are PIDS because: Let I be an ideal. Let a be the least positive number in a. The claim is I=(a), multiples of a. Suppose not. Then let b be the least positive number that's not a multiple of a. But then b-a is not a multiple of a either, so by choice of b, b-a is not positive. Clearly b=/=a, so b<a, contradicting the choice of a.

Rationals are PIDS because: The rationals form a field so the only ideals are the trivial ones, which are trivially principal.

That was just recalling some facts.

Now let R be a ring as in the problem statement. There might be a simpler solution than the one I propose, but it's all I can think of.

We know R contains Z, so letting I be an ideal of R, and letting I' be the intersection of I with Z, I' is an ideal of Z, and is thus principal. Let a be the generator of I'.

Now, for each m, Am={n: n/m is in R} is an ideal of Z, as is Bm={n: n/m is in I}. Since Z is a PID, these ideals are principal. Let their generators be am and bm, respectively. The first thing to notice is that 0<am<=m since 1 is in R. In fact, am divides m because Am is a principal ideal. Now, I claim bm=a*am for each am. Indeed, a*am is an element of Bm since a*am/m is in I because am/m is in R, so b divides a*am. But b is also a multiple of am by definition of am. So write b=d*am, where d divides a. But am divides m as discussed above, so fix k s.t. k*am=m. So k*(b/m)=d, and it is an element of I since k is in R and b/m is in I, so d=a by choice of a, so b=a*am, as desired.

Finally, we can conclude I is principal, generated by a. For suppose x=n/m is in I. So we know n is a multiple of a*am. So x/a is an integer multiple of am/m, so x/a is in R. So x is the product of a and an element of R, as desired.