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.