S
S
Sergey Brava2017-01-10 13:16:20
MySQL
Sergey Brava, 2017-01-10 13:16:20

After mysqli_connect(); gives the penultimate value, session reset?

Just PHP
=============================================== ============================

include ABSPATH . "/ns-connect.php";
  $result     = mysqli_query($connection, "SELECT * FROM `wp_ign_pay_info` ORDER BY `id` DESC");

  // Getting product_id
  $last_order = mysqli_fetch_assoc($result);
  $product_id = $last_order['product_id'];

  // Getting product_title
  $query_product_title = mysqli_query($connection, "SELECT * FROM `wp_ign_products` WHERE `id` = $product_id");
    $product_name        = mysqli_fetch_assoc($query_product_title);
    $project_name        = $product_name['product_name'];

WordPRess way
=============================================== ==================
global $wpdb;

$latest_order = $wpdb->get_results("SELECT * FROM `wp_ign_pay_info` ORDER BY `id` DESC LIMIT 1");
$txn_id = $latest_order[0]->transaction_id;

$result = $wpdb->get_results("SELECT * FROM `wp_ign_pay_info` WHERE `transaction_id` = '$txn_id'");
$product_id = $result[0]->product_id;

$query_product_title = $wpdb->get_results("SELECT * FROM `wp_ign_products` WHERE `id` = $product_id");
$product_name = $query_product_title[0]->product_name;

Then I request the necessary parameters through wp-functions, but after the second time, the script starts giving me the penultimate entry by id, instead of the last one.
If it (a request with data) was in the last session, then the request issues the next one in descending order.
Question: How to properly reset a session or request?
And would each time to receive the last record in the table?

Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question