Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

201
Vistas
Wordpress PHP with Screen Width condition

Hey guys i am trying to foreach array from my table and i want to foreach specific rows that only for mobie if user use mobile, and foreach rows that only for desktop if user screen more than 720px but the first condition only working, and the second one not working. so where is there problem here?

$table_header_name = 'header'; // Table Name
$width = "<script>document.write(screen.width);</script>";

if($width <= 720) { //this for mobile & tablet
  $h_rows = $wpdb->get_results( "SELECT * FROM  $table_header_name WHERE play_mode = 1 AND device_mode = 1 ORDER BY rank_mode ASC", ARRAY_A );
}
elseif($width >= 721) { //this for desktop
 
  $h_rows = $wpdb->get_results( "SELECT * FROM  $table_header_name WHERE play_mode = 1 AND device_mode = 0 ORDER BY rank_mode ASC", ARRAY_A );
}

i use this code in sidebar widget in my plugin files.

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda