ESH/save_all_menue_rename.php
2024-10-23 18:28:06 +05:30

69 lines
1.4 KiB
PHP

<?php
error_reporting(E_ERROR | E_PARSE);
include ('includes/config/config.php');
include ('includes/functions.php');
include('log_entry.php');
begin();
$query = "select * from menu_master ";
error_log("sql " . $query);
if (!$result = @mysqli_query($conn,$query)) {
rollback();
exit(mysqli_error($conn));
}
$data = array();
if(mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
error_log('word'.$row['menu_name']);
$menu_id=$row['menu_id'];
$menu_name=$row['menu_name'];
$name_parts =explode(" ",$menu_name);
$new_name='';
for($i=0;$i<count($name_parts);$i++){
$word='';
$first_alpha='';
$all_alpha='';
$first_alpha.=substr($name_parts[$i], 0, 1);
$all_alpha.=substr($name_parts[$i], 1, );
$word=strtoupper($first_alpha).strtolower($all_alpha);
if($i<(count($name_parts)-1)){
$new_name.=$word.' ';
}else{
$new_name.=$word;
}
}
$sql = "UPDATE menu_master SET menu_name='".$new_name."' where menu_id='".$menu_id."' ";
error_log('----'.$sql);
if (!$result_sql = @mysqli_query($conn,$sql)) {
rollback();
exit(mysqli_error($conn));
}
}
$data['status'] = "succes";
$data['message'] = "Assign menu done!";
}
else
{
$data['status'] = 200;
$data['message'] = "Data not found!";
}
commit();
echo json_encode($data);
?>