If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

the first bit is php; that's run on the server; think of it as preparing the contents of the page for the user; it pulls templates together, loads in data, lays out the page etc.

but browser width is a client issue; so to do that you need to do it with javascript.

you've started to do that; your php outputs some javascript which determines and prints the window width. that's fine, except there's no way to get that value from the javascript back into php; because by the time that javascript starts executing, the php has already finished executing; its too late.

so what you need to do is put the logic you're trying to achieve (if this.. else...) into javascript.

if you really, really, really had to have the window width value on the server side, then there are cumbersome and ways of doing this, but for the most part, between CSS and Javascript, you should be able to achieve what ever layout you're trying to achieve.