gpt4 book ai didi

php - 代码点火器 :How to pass search term in redirect

转载 作者:行者123 更新时间:2023-11-29 15:44:01 27 4
gpt4 key购买 nike

我使用 PHP 和 MySQL 使用 codeigniter 制作了一个简单的项目。该项目使用户能够通过添加新产品和更新每个产品的库存来管理他的仓库。现在,当用户搜索产品并更新库存值(value)时,应用程序会更新数据库并刷新页面并显示所有产品。有没有办法传递他使用的搜索词,甚至更好地传递他在重定向中更改的产品。非常感谢。

function prevazia($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('admin_login') != 1)
redirect(base_url() . 'index.php?login');
if ($param1 == 'edit')
{
$data['type'] = $this->input->post('type');
$data['color'] = $this->input->post('color');
$addition = $this->input->post('addition');
$data['stock'] = $this->input->post('stock') + $addition;
$data['stock_alert'] = $this->input->post('stock_alert');
//-----------------------------------------
include('dbc.php');
mysqli_query($conn,"SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
$sql9 = "SELECT * FROM prevazia_log order by id desc LIMIT 1";
$result = mysqli_query($conn, $sql9);
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
$last_id=$row['id']+1;
}
}
date_default_timezone_set('Europe/Athens');
//$result6 = mysqli_query($conn, $sql);
//$additionDate = DateTime::createFromFormat('d/m/Y H:i');
//$myAdditionDate = $additionDate->format('Y-m-d H:i');
$log['id'] = $last_id;
$log['user'] = $this->session->userdata('name');
$log['create_timestamp'] = date("d-m-y h:i:sa");
$log['type'] = $this->input->post('type');
$log['color'] = $this->input->post('color');
$log['previous_stock'] = $this->input->post('stock');
$log['addition'] = $this->input->post('addition');
$log['new_stock'] = $this->input->post('stock') + $this->input->post('addition');
//--------------------
//$data['role'] = $this->input->post('role');
$this->db->insert('prevazia_log', $log);
$this->db->where('id', $param2);
$this->db->update('prevazia', $data);
// UPLOAD IMAGE FILE
$this->session->set_flashdata('flash_message', translate('informations_updated'));
redirect(base_url() . 'index.php?admin/prevazia', 'refresh');
}
if ($param1 == 'delete')
{
$this->db->where('id', $param2);
$this->db->delete('prevazia');
$this->session->set_flashdata('flash_message', translate('data_deleted'));
redirect(base_url() . 'index.php?admin/prevazia', 'refresh');
}
$page_data['page_name'] = 'prevazia';
$page_data['page_title'] = 'Πρεβάζια';
$page_data['prevazia'] = $this->db->get_where('prevazia', array('active'=> $GLOBALS['flag']))->result_array();
$this->load->view('backend/index', $page_data);
}

编辑:最好是我可以传递 $data['type'] 和 $data['color'],这样当它重定向时,它会将这些值传递到搜索框。

最佳答案

如果您使用带有方法 post 的表单提交,则应该通过 View 返回搜索参数

$data['search_param'] =  $post['search_param'];
$this->load->view('view_page', $data);

<input name="search_param" value="<?php echo !empty($search_param) ? $search_param : ''?>">

关于php - 代码点火器 :How to pass search term in redirect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57269991/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com