help with while loop

Hi, in changeing from MYSQL to MYSQLi (that's where the blame goes) I can't get a clear understanding as to the proper code
for the while loop. help please. code follows:
——————————————————
<html><body>
<hr>
<center><b><font size=+2> 515 Certification Expiration Report</font><br>06/22/2020 – 06/22/2021<p>

<hr>

<?php
//Open a new connection to the MySQL server
require_once "getprerentdb.php";

//MySqli Select Query
$ results = $ mysqli->query (SELECT * FROM…

help with while loop

Change query based on post type while staying in loop

I have a loop that displays three custom post types.

Thing is, all of these post types use a different logic. ‘elemzesek’ and ‘gyorshirek’ use ACF fields which you can see in the meta_query.

However, the ‘cikkek’ post type, to display the correct articles, would need a

‘tag’ => get_the_title();

The problem is, if this is added, and it runs for ‘elemzesek’ and ‘gyorshirek’ as well, the loops finds no results.

Can someone help me in achieving this?

<?php      $  ceg = get_the_title();     $  ceg_megadasa = get_field('ceg_megadasa');     $  paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;     $  query = new WP_Query( array(         'post_type' => array('cikkek', 'elemzesek', 'gyorshirek'),         'posts_per_page' => 10,         'paged' => $  paged,         'post_status' => 'publish',         // 'tag' => $  ceg,         'orderby' => 'date',         'order' => 'DESC',         'meta_query' => array(             'relation' => 'OR',             array(                 'key' => 'ceg_megadasa',                 'value' => get_the_ID()             ),             array(                     'key' => 'ceg_megadasa_gyorshirek',                     'value' => get_the_ID()                 ),                      )     ) ); ?> 

Change AJAX Live Post Search Loop into foreach

I was told that the reason for why the live post search does not work is because the loop needs changing into a foreach.

This is the code:

add_action( 'wp_ajax_data_fetch' , 'data_fetch' ); add_action( 'wp_ajax_nopriv_data_fetch', 'data_fetch' ); function data_fetch() {      global $  wpdb;     $  post_search_query = $  wpdb->get_results("SELECT * FROM wp_posts where post_type = 'post' and post_title like '%'".esc_attr( $  _POST['search_keyword'] )."'%'");          if( $  post_search_query->have_posts() ) :                  while( $  post_search_query->have_posts() ): $  post_search_query->the_post(); ?>                          <h5><a href="<?php echo esc_url( post_permalink() ); ?>"><?php the_title();?></a></h5>             <span class="live-search-product-excerpt"><?php the_excerpt(); ?></span>              <?php endwhile;         wp_reset_postdata();     endif;     die(); } 

The search is dead. It shows nothing. Can someone please help me with this as I am at a loss. Here is the rest of the code:

add_shortcode('live_search', 'live_search_shortcode'); function live_search_shortcode(){      $  live_search = '<input type="text" class="live-search" name="postSearch" id="postSearch" placeholder="Type to Live Search"></input>     <div id="datafetch"></div>';          return $  live_search; }  add_action('wp_footer', 'jquery_live_search_data_fetch'); function jquery_live_search_data_fetch() { ?>      <script type="text/javascript">                  (function($  ){              var searchRequest = null;                                  jQuery(function (){                                      var minlength = 3;                                  jQuery("#postSearch").keyup(function (){                                          var that = this,                                      value = jQuery(this).val();                                  if (value.length >= minlength){                                      if (searchRequest != null)                      searchRequest.abort();                                  searchRequest = jQuery.ajax({                                      type: "POST",                     url: "<?php echo admin_url('admin-ajax.php'); ?>",                 data: {                 action: 'data_fetch',                 search_keyword : value                 },                                  dataType: "html",                 success: function(data){                                          if (value==jQuery(that).val()) {                                              jQuery('#datafetch').html(data);                     }                 }             }         );     } else {      jQuery('#datafetch').html( '' );     }   } ); }); } (jQuery));     </script> <?php } 

Custom Loop with certain number of one category

I have a custom loop that goes like this:

            global $  post;             $  tmp_post = $  post;             $  args = array(              'numberposts' => '120',             'orderby' => 'date',             'order'   => 'DESC',             'cat' => array(1,2,7,8,9,27, 30, 31),             'tax_query' => array(                         array(                             'taxonomy' => 'post_format',                             'field' => 'slug',                             'terms' => array( 'post-format-aside','post-format-video' ),                             'operator' => 'NOT IN',                         ),                     )          );             $  myposts = get_posts( $  args );             foreach( $  myposts as $  post ) : setup_postdata($  post);          ?> 

What I need is not a output of 120 posts in total, but 120 posts only of the category with the ID 2. Is that possible?

Thanks

is Mithral full plate armor a loop hole?

We are playing a one-shot at Level 7 and I allowed the players to choose 1 magic item of rarity uncommon and minor tier for their character. Also they can have items worth 300 Gold in addition to starting items.

One of the players wrote me whether it is a loophole to choose a Mithral full plate Armor (DMG 182) as magic item. A full plate armor costs 1.500 Gold and is therefore way out of reach for the starting Gold, however as mithral full plate armor it is a uncommon minor (XGE 141) magic item. Since it is just a one-shot I’m not so concerned about it, but in general I think this might be a problem. For example in a campaign such a rule could allow new characters to appear with full plate at level 7. So my question is:

Is Mithral full plate armor a loophole to abuse such starting magic items or is it balanced to get this item at level 7?

Optimizing a slow For loop

I know that this is a "beginner question", and, in fact, I am. I want to improve my code, as it takes really too much time to run. I have already read some other discussions, like here, but I am struggling in translating the simplifications with Table or Do into my example.

The For cycle I want to improve is the following:

zh = 0.4; list = {}; eqdiff = phi''[x] + 2*phi'[x]/x + (2*(zg + zh*Exp[-zh*x/dh])/x + 1)*phi[x] == 0; For[i = 0, i < 10000, i++,      With[{zg = -0.6, dh = i*10^-2},           nsol = Block[{eps = $  MachineEpsilon},           NDSolve[{eqdiff, phi[eps] == 1, phi'[eps] == -(zg + zh)}, phi, {x, eps, 20000},                   WorkingPrecision->MachinePrecision, AccuracyGoal->15, PrecisionGoal->8, MaxSteps->Infinity]]];       AppendTo[list, 1/Evaluate[(15000*phi[15000])^2 + ((15000-Pi/2)*phi[15000-Pi/2])^2 /. nsol[[1]]]];] 

Clearly, this code, written in this way, is highly inefficient. Also, I need to do more of these, with different values for zg inside With, and make some plots out of the lists.

Anyone that can help me with this noob question? Thanks a lot!

How do I make my terms for each product display via foreach loop? (woocommerce)

This is my current loop to display my products via woocommerce. When I do print_r($ category_array); It returns the array, but when I try to use a function to call it so I can do what I want to with the data, it makes and my entire screen doesn’t display after the loop. Maybe it’s a mistake in my function? Still very new to woocommerce and wp_loops. Thank you

            <?php             // WP_Query arguments             $  args = array(                 'p'                      => 'product',                 'post_type'              => array( 'product' ),                 'order'                  => 'ASC',                 'post_per_page' => 20,             );              // The Query             $  query = new WP_Query( $  args );              // The Loop             if ( $  query->have_posts() ) {                 while ( $  query->have_posts() ) {                     $  query->the_post();                     function filter_categories($  categories) {                             foreach ($  categories as $  category) {                                 echo $  category->name;                             }                     }                       ?>                     <div class="row">                         <div class="col-2">                             <?php echo the_post_thumbnail(get_the_ID(), 'thumbnail'); ?>                         </div>                         <div class="col-7">                             <a href="<?= get_permalink(); ?>"><?= the_title()?></a>                             <br/>                             <?php                             $  category_array = get_the_terms(get_the_ID(), 'product_cat');                             filter_categories($  category_array);                             ?>                         </div>                         <div class="col-3 text-right ">Price</div>                     </div>                     <?php                 }             } else {                 // no posts found             }              // Restore original Post Data             wp_reset_postdata();             ?> 

Query in do loop

Why is the following code not working? :

Do[gm = 200*N[Pi];  s1 = k^2 + (d - ((g1^2)*points[i, 2, 1]/wm))^2 + 2*k*gm + wm^2;  s2 = (k^2 + (d - ((g1^2)*points[i, 2, 1]/wm))^2)*gm + 2*k*wm^2;  s3 = (k^2 + (d - ((g1^2)*points[i, 2, 1]/wm))^2)*(wm^2) - (d - (g1^2*         points[i, 2, 1]/wm))*wm*(g1^2)*(2 points[i, 2, 1]);  If[(2 k + gm) s1 > s2, Print[True], Print[False]];  If[s1*s2 (2 k + gm) > s2^2 + (2 k + gm)^2*(s3), Print[True],    Print[False]];  If[s1 > 0, Print[True], Print[False]];  If[s2 > 0, Print[True], Print[False]];  If[s3 > 0, Print[True], Print[False]], {i, 11}] 

Please suggest ways to tweak this or an alternative method.