Let $R$ be a commutative ring with identity and $x, y $ be fixed elements of $R$ such that for each maximal ideal $m$ of $R$ we have $\langle \frac{x}{1_m}\rangle\subseteq\langle \frac{y}{1_m}\rangle$ or $\langle \frac{y}{1_m}\rangle\subseteq\langle \frac{x}{1_m}\rangle$ in the ring $R_m$, (that is, $\langle \frac{x}{1_m}\rangle\subseteq\langle \frac{y}{1_m}\rangle$ for a maximal ideal $m$ of $R$ and $\langle \frac{y}{1_n}\rangle\subseteq\langle \frac{x}{1_n}\rangle$ for another maximal ideal $n$ of $R$) where $R_m$ is the localization of $R$ at $m$. I am looking for conditions under which that property implies $\langle x\rangle\subseteq\langle y\rangle$ or $\langle y\rangle\subseteq\langle x\rangle$ in the ring $R$.

$\begingroup$ Do you mean that for each ideal, we always have the same relation? Or is the containment allowed to be in one direction for one maximal ideal and in another one for a different one? $\endgroup$ – Dirk Jul 12 at 14:22

$\begingroup$ I have added some edition. $\endgroup$ – Asad Albani Jul 12 at 15:14

$\begingroup$ Try the simplest example: $R=\mathbb Z$. Then every maximal ideal is of the form $m=(p)$ where $p$ is a prime number. Then $R_m={\mathbb Z}_{(p)}$ is a DVR, so every two ideals are related by containment. On the other hand, there are plenty of pairs of integers $(x,y)$ such that $x\not\mid y$ and $y\not\mid x$. $\endgroup$ – Fan Zheng Jul 12 at 16:40

$\begingroup$ On the other hand, the conclusion is true if $R$ is itself a local ring, in which $R_m$ is identical to $R$. $\endgroup$ – Fan Zheng Jul 12 at 16:50
The conclusion is true if and only if $R$ has at most 1 maximal ideal, i.e., $R$ is either itself a local ring, or the zero ring. The "if" part is trivial: for the case of local ring see the comment above, and the zero ring is even more trivial. and we now show the "only if" part by contrapositive.
Suppose $R$ has at least 2 maximal ideals $m$ and $n$. Since $m+n=(1)$, by the Chinese Remainder Theorem, there is $x\in R$ such that $x=1\pmod m$ and $x=0\pmod n$. Set $y=x+1$. Then there is no maximal ideal containing both $x$ and $y$. In other words, for any maximal ideal $p$, either $x\notin (p)$ or $y\notin (p)$. Then either $(x)_{(p)}$ or $(y)_{(p)}=(1)$ in $R_{(p)}$, which then contains every other ideal. On the other hand, $(x)$ and $(y)$ does not contain each other, for otherwise either $(x)$ or $(y)$ would contain 1, that is, either $x$ or $y$ would be a unit, but both $x\in (n)$ and $y\in (m)$ cannot be units, contradiction.