File: /var/www/doco2/wp-content/themes/ormedia/page-change-ref.php
<?php
//Template Name: refchange
$statement = "SELECT property_id, ref FROM keylab_property WHERE ref = ''";
$results = $wpdb->get_results($statement);
foreach($results as $value){
$wpdb->update("keylab_property",[
'ref' => '#'.$value->property_id
], [
'property_id' => $value->property_id
]);
}
// $statement = "SELECT * FROM `keylab_users` WHERE category != ''";
// $results = $wpdb->get_results($statement);
// $ss = 1;
// $oc = 1;
// $cc = 1;
// foreach($results as $value){
// if($value->category == 'contractor'){
// $wpdb->update("keylab_users",[
// 'index_id' => $cc
// ], [
// 'user_id' => $value->user_id
// ]);
// $cc++;
// }
// if($value->category == 'propman'){
// $wpdb->update("keylab_users",[
// 'index_id' => $ss
// ], [
// 'user_id' => $value->user_id
// ]);
// $ss++;
// }
// if($value->category == 'oc'){
// $wpdb->update("keylab_users",[
// 'index_id' => $oc
// ], [
// 'user_id' => $value->user_id
// ]);
// $oc++;
// }
// }