Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP and CSS media queries 1

Status
Not open for further replies.

PeDa

Technical User
Oct 10, 2002
227
NL
I need to display my PHP data is quite different tables on desktop and mobile phone. At the moment I generate both versions in one webpage and then hide the inappropriate one using media queries. Is there a more elegant way of achieving this? (the difference is too great to use, for example, this procedure)
 
I initially wrote the text below the line, but now see that your suggestion must be what I need: te detect the type of device on the server side and not on the client side. Thank you.

------------------------------------------------------------------------------------------------

Thank you, but detecting the mobile phone is not my problem (my media queries seem to manage that ok); it is what to do after that. I now have:
Code:
@media screen and (max-width:600px) {.bigTable {display:none}}
@media screen and (min-width:601px) {.smallTable {display:none}}
followed by
Code:
<div bigTable>
big loop with lots of php and html
</div>
<div smallTable>
big loop with lots of different php and html
</div>

While this works perfectly satisfactorily, it isn't very elegant because half of the work is unnecessary and not shown. I am just wondering if there is a more elegant solution (but realise that would seem to require the client to communicate with the server).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top