Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!