here's query:
global $wpdb; $result = $wpdb->get_results( "select name_mycolumn name_table"); foreach ( $result $row ) { $data = "$row-> name_mycolumn|"; } $val = "'/\b($data)\b/i'"; echo $val; i this:
'/\b(word1|)\b/i' where word1 last value.
instead, have this:
'/\b(word1|word2|word3|word4|.......)\b/i' my goal column values not last.
thank all, 3 solutions proposed not work well. result same :( in table there on 1 hundred words have:
'/\b(word1|word2|word3|word4|word5|word6|word7|word8| is there solution ?
edit
i have understand where's error. have accidentally added database word id9 < word9 , (<) has broken code after word id 8
you use $wpdb->get_col fetch array of values. use implode join them |.
global $wpdb; $result = $wpdb->get_col( "select name_mycolumn name_table"); $data = implode('|', $result); $val = "'/\b($data)\b/i'";
Comments
Post a Comment